bumpit 0.3.0 → 0.3.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 +4 -4
- data/lib/bumpit/managers/base.rb +2 -2
- data/lib/bumpit/managers/bundler.rb +34 -14
- data/lib/bumpit/version.rb +1 -1
- 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: 61dc3fe86a1ce8d55b8cd34773cfff73c8beb459bc4964d7beb2dd008506745b
|
|
4
|
+
data.tar.gz: 8f12b7cf3e4128b9ec0f7a5776779d89bf31b3fd31c450f552d814f75b7fb67d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a8bbfd7d4cf366219f71f0de32ea6b3e08fa029326095e45cf8b30281fdb304429fe2f2fe30e9ddc65001f1063b925e044bfe048707eea7372028aeb60b1409
|
|
7
|
+
data.tar.gz: d4ae18ad6a77baa29373022fe79ec62b0627428a0742533fd5439d0fc77de15c03eae97a623c3b6421036ac43f9f1ec1b999b677b9224cba8196b14076d421a1
|
data/lib/bumpit/managers/base.rb
CHANGED
|
@@ -6,14 +6,16 @@ require "pathname"
|
|
|
6
6
|
class Bumpit
|
|
7
7
|
module Managers
|
|
8
8
|
class Bundler < Base
|
|
9
|
-
|
|
10
|
-
BUNDLER_UPDATE_COMMAND = "bundle update --bundler"
|
|
9
|
+
BUNDLED_WITH_MATCHER = /^BUNDLED WITH\n\s+(.+)$/
|
|
10
|
+
BUNDLER_UPDATE_COMMAND = "bundle update --bundler=%s"
|
|
11
11
|
DEPENDENCY_MATCHER = /^\s*gem\s+['"]([^'"]+)['"].*$/
|
|
12
|
-
|
|
12
|
+
GEMFILE = "Gemfile"
|
|
13
|
+
GEMFILE_LOCK = "Gemfile.lock"
|
|
14
|
+
FILENAMES = [GEMFILE, GEMFILE_LOCK].freeze
|
|
13
15
|
GEM_INFO_COMMAND = "gem info --exact --remote --no-prerelease --no-verbose bundler"
|
|
14
16
|
INFO_MATCHER = /bundler \(([^)]+)\)/
|
|
15
17
|
OUTDATED_COMMAND = "bundle outdated --only-explicit --parseable 2>/dev/null"
|
|
16
|
-
OUTDATED_MATCHER = /\A(
|
|
18
|
+
OUTDATED_MATCHER = /\A(\S+) \(newest ([^,)]+), installed ([^,)]+), requested = ([^,)]+)/
|
|
17
19
|
|
|
18
20
|
# Determine if the manager is valid.
|
|
19
21
|
#
|
|
@@ -29,12 +31,12 @@ class Bumpit
|
|
|
29
31
|
#
|
|
30
32
|
# @return [void]
|
|
31
33
|
def bump
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if outdated.any?
|
|
34
|
+
if outdated?
|
|
35
35
|
write_contents
|
|
36
36
|
bundle_update
|
|
37
37
|
end
|
|
38
|
+
|
|
39
|
+
update_bundler
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
# Return a message for which dependencies were bumped.
|
|
@@ -68,7 +70,7 @@ class Bumpit
|
|
|
68
70
|
#
|
|
69
71
|
# @return [String] The contents of the Gemfile.
|
|
70
72
|
def contents
|
|
71
|
-
@contents ||= File.read(
|
|
73
|
+
@contents ||= File.read(GEMFILE)
|
|
72
74
|
end
|
|
73
75
|
|
|
74
76
|
# Return the modified contents of the Gemfile.
|
|
@@ -87,6 +89,13 @@ class Bumpit
|
|
|
87
89
|
end
|
|
88
90
|
end
|
|
89
91
|
|
|
92
|
+
# Return the latest released version of Bundler.
|
|
93
|
+
#
|
|
94
|
+
# @return [String]
|
|
95
|
+
def latest_bundler_version
|
|
96
|
+
@latest_bundler_version ||= INFO_MATCHER.match(`#{GEM_INFO_COMMAND}`).to_a.last.to_s
|
|
97
|
+
end
|
|
98
|
+
|
|
90
99
|
# Return the outdated dependencies.
|
|
91
100
|
#
|
|
92
101
|
# @return [Hash]
|
|
@@ -100,12 +109,22 @@ class Bumpit
|
|
|
100
109
|
end
|
|
101
110
|
end
|
|
102
111
|
|
|
112
|
+
# Determine if there are outdated dependencies, including Bundler.
|
|
113
|
+
#
|
|
114
|
+
# Checks update_bundler? first to cache the result before bundle_update
|
|
115
|
+
# modifies the lock file.
|
|
116
|
+
#
|
|
117
|
+
# @return [Boolean]
|
|
118
|
+
def outdated?
|
|
119
|
+
update_bundler? || outdated.any?
|
|
120
|
+
end
|
|
121
|
+
|
|
103
122
|
# Update Bundler in the lock file.
|
|
104
123
|
#
|
|
105
124
|
# @return [void]
|
|
106
125
|
def update_bundler
|
|
107
126
|
if update_bundler?
|
|
108
|
-
`#{BUNDLER_UPDATE_COMMAND}`
|
|
127
|
+
`#{format(BUNDLER_UPDATE_COMMAND, latest_bundler_version)}`
|
|
109
128
|
end
|
|
110
129
|
end
|
|
111
130
|
|
|
@@ -113,11 +132,12 @@ class Bumpit
|
|
|
113
132
|
#
|
|
114
133
|
# @return [Boolean]
|
|
115
134
|
def update_bundler?
|
|
116
|
-
@update_bundler
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
return @update_bundler if defined?(@update_bundler)
|
|
136
|
+
|
|
137
|
+
@update_bundler = begin
|
|
138
|
+
_, current = BUNDLED_WITH_MATCHER.match(File.read(GEMFILE_LOCK)).to_a
|
|
119
139
|
|
|
120
|
-
Gem::Version.new(
|
|
140
|
+
Gem::Version.new(latest_bundler_version) > Gem::Version.new(current.to_s)
|
|
121
141
|
end
|
|
122
142
|
end
|
|
123
143
|
|
|
@@ -125,7 +145,7 @@ class Bumpit
|
|
|
125
145
|
#
|
|
126
146
|
# @return [void]
|
|
127
147
|
def write_contents
|
|
128
|
-
File.write(
|
|
148
|
+
File.write(GEMFILE, "#{modified_contents.join("\n")}\n")
|
|
129
149
|
end
|
|
130
150
|
end
|
|
131
151
|
end
|
data/lib/bumpit/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bumpit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tristan Dunn
|
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
74
|
version: '0'
|
|
75
75
|
requirements: []
|
|
76
|
-
rubygems_version: 4.0.
|
|
76
|
+
rubygems_version: 4.0.23
|
|
77
77
|
specification_version: 4
|
|
78
78
|
summary: Automatically bump dependencies in multiple package managers.
|
|
79
79
|
test_files: []
|