dependency_bumper 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 54d2879efa17d4a62f8a531414c0d67ac95d774da249431cdadaadf43ba29157
4
+ data.tar.gz: b4e2628341bbf26bc75933e8d464d7531e37c1c13b7799c15499cae9e6c509e7
5
+ SHA512:
6
+ metadata.gz: 1eea351afe7f434b9f26b9127f1b6a03b1254120c5516d97af31b3cb541a5182b216573c032d91004571c3596cc42d686699496f7b2f444e8b18e8824840f05c
7
+ data.tar.gz: a223580ab01c8eb61fddfa1bced5d247d648ef2b800d6b47c4d8c4c968b3096a1ed41be248554bf5cb6a39f9df127aa7830c67f81bbe4ab51b428e1e579447fa
@@ -0,0 +1,32 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ # Push events to branches matching refs/heads/releases/10
7
+ - 'releases/**'
8
+ pull_request:
9
+ branches: [ master ]
10
+
11
+ jobs:
12
+ build:
13
+ name: Build + Publish to RubyGems
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Set up Ruby 2.6
19
+ uses: actions/setup-ruby@v1
20
+ with:
21
+ ruby-version: 2.6.x
22
+
23
+ - name: Publish to RubyGems
24
+ run: |
25
+ mkdir -p $HOME/.gem
26
+ touch $HOME/.gem/credentials
27
+ chmod 0600 $HOME/.gem/credentials
28
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29
+ gem build *.gemspec
30
+ gem push *.gem
31
+ env:
32
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,33 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
+ # uses: ruby/setup-ruby@v1
27
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
28
+ with:
29
+ ruby-version: 2.6
30
+ - name: Install dependencies
31
+ run: bundle install
32
+ - name: Run tests
33
+ run: bundle exec rake
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,17 @@
1
+ Layout/LineLength:
2
+ Enable: false
3
+
4
+ Metrics/ClassLength:
5
+ Enable: false
6
+
7
+ Style/WordArray:
8
+ Enabled: false
9
+
10
+ Style/TrailingCommaInArrayLiteral:
11
+ Enabled: false
12
+
13
+ Style/TrailingCommaInHashLiteral:
14
+ Enabled: false
15
+
16
+ Style/MethodCallWithoutArgsParentheses:
17
+ Enable: false
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.6
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ ## [Unreleased]
5
+
6
+ ## [1.0.0] - 2020-08-07
7
+ ### Added
8
+ - Dry mode
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at eldemcan@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
@@ -0,0 +1,4 @@
1
+ FROM ruby:2.6
2
+ RUN gem install bundler:2.1.4
3
+ RUN git config --global user.email "you@example.com"
4
+ RUN git config --global user.name "Your Name"
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in dependency_bumper.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dependency_bumper (0.1.0)
5
+ bundler (~> 2.1)
6
+ git (~> 1.7)
7
+ thor (~> 0.19)
8
+ zeitwerk (~> 2.3)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ byebug (11.1.3)
14
+ console (1.9.0)
15
+ diff-lcs (1.4.4)
16
+ git (1.7.0)
17
+ rchardet (~> 1.8)
18
+ rake (12.3.3)
19
+ rchardet (1.8.0)
20
+ rspec (3.9.0)
21
+ rspec-core (~> 3.9.0)
22
+ rspec-expectations (~> 3.9.0)
23
+ rspec-mocks (~> 3.9.0)
24
+ rspec-core (3.9.2)
25
+ rspec-support (~> 3.9.3)
26
+ rspec-expectations (3.9.2)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.9.0)
29
+ rspec-mocks (3.9.1)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.9.0)
32
+ rspec-support (3.9.3)
33
+ thor (0.20.3)
34
+ zeitwerk (2.4.0)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ byebug (~> 11.1, >= 11.1.3)
41
+ console (~> 1.8)
42
+ dependency_bumper!
43
+ rake (~> 12.0)
44
+ rspec (~> 3.0)
45
+
46
+ BUNDLED WITH
47
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 can eldem
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,77 @@
1
+ # DependencyBumper
2
+
3
+ Dependency Bumper is a simple tool helps you to automate updating dependencies of your Ruby project.
4
+
5
+ ## Usage
6
+
7
+ - Add dependency_bumper to your dependencies
8
+ - Go to your project's directory in terminal and write `dbump bump_gems` . It will update gems with default configuration.
9
+ - `dbump help bump_gems` will give you arguments for the command. This is the only command!
10
+ - You can also integrate dependency bumper to your program by simply calling `Updater.new(config).run`
11
+
12
+ ## Configuration
13
+
14
+ You can tune behaviour of dependency bumper with configuration, it will run with default configuration if not specified
15
+
16
+ ### Example configuration file
17
+
18
+ By default it will look for a file called `.bumper_config.json"` but you can specify config file as you wish. (Check `dbump help bump_gems`)
19
+
20
+ ```json
21
+ {
22
+ "skip": {
23
+ "thor": true,
24
+ "parslet": true
25
+ },
26
+ "outdated_level": "strict",
27
+ "update": {
28
+ "default": "minor",
29
+ "major": { "console" : true },
30
+ "minor": { "active_record": true, "async": true },
31
+ "patch": { "rails": true }
32
+ }
33
+ }
34
+ ```
35
+
36
+ `outdated_level` = By default dependency_bumper only lists newer versions allowed by your Gemfile requirements. Other values `("major", "minor", "patch")` .
37
+
38
+ `update.default` = Default update level. You can easily tune this behaviour specific to gems. In example above, `console` gem will be updated next major version meanwhile `rails` gem will be only patch levels updates will be applied. All other dependencies will get `minor` level updates.
39
+
40
+ #### Default config
41
+
42
+ Default configuration values can be found [in cli.rb](https://github.com/spandx/dependency_bumper/blob/master/lib/dependency_bumper/cli.rb#L5)
43
+
44
+ ### Integration with git
45
+
46
+ ```dbump bump_gemps --git``` command will create another branch (i.e "08-09-2020"), update your dependencies and and commit changes. Commit message body will include details of your update. I.e,
47
+
48
+ ```
49
+ gem-bump-08-09-2020
50
+
51
+ parslet From 1.8.2 To 1.8.3 update level: patch
52
+ thor From 0.20.3 To 1.0.0 update level: major
53
+ zeitwerk From 2.3.0 To 2.4.0 update level: patch
54
+ ```
55
+
56
+ ### Similar projects
57
+
58
+ - https://github.com/mvz/keep_up
59
+ - https://github.com/attack/lapidarist
60
+ - https://github.com/wemake-services/kira-dependencies
61
+ - https://github.com/singlebrook/bunup
62
+ - https://github.com/dependabot/dependabot-core/tree/main/bundler/lib/dependabot/bundler
63
+
64
+ ## Development
65
+
66
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
67
+
68
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
69
+
70
+ ## Contributing ٩(◕‿◕。)۶
71
+
72
+ Bug reports and pull requests are welcome on GitHub at https://github.com/spandx/dependency_bumper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/dependency_bumper/blob/master/CODE_OF_CONDUCT.md).
73
+
74
+
75
+ ## License
76
+
77
+ The gem is available as open source under the terms of the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'dependency_bumper'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/dependency_bumper/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'dependency_bumper'
7
+ spec.version = DependencyBumper::VERSION
8
+ spec.authors = ['Can Eldem', 'Mo Khan']
9
+ spec.email = ['eldemcan@gmail.com', 'mo@mokhan.ca']
10
+
11
+ spec.summary = ' Tool helps you to automate updating dependencies of your Ruby project. '
12
+ spec.homepage = 'https://github.com/spandx/dependency_bumper'
13
+ spec.license = 'Apache-2.0'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
15
+
16
+ # spec.metadata['allowed_push_host'] = 'TODO: Set to 'http://mygemserver.com''
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/spandx/dependency_bumper'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/spandx/dependency_bumper'
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
30
+
31
+ spec.add_runtime_dependency 'git', '~> 1.7'
32
+ spec.add_runtime_dependency 'thor', '~> 0.19'
33
+ spec.add_development_dependency 'byebug', '~> 11.1', '>= 11.1.3'
34
+ spec.add_development_dependency 'console', '~> 1.8'
35
+ spec.add_runtime_dependency 'bundler', '~> 2.1'
36
+ spec.add_runtime_dependency 'zeitwerk', '~> 2.3'
37
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'dependency_bumper'
5
+ require 'console'
6
+
7
+ Signal.trap('INT') do
8
+ exit(1)
9
+ end
10
+
11
+ begin
12
+ DependencyBumper::Cli.start(ARGV)
13
+ rescue StandardError => e
14
+ Console.logger.error(e.message)
15
+ exit 1
16
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler'
4
+ require 'bundler/cli'
5
+ require 'bundler/cli/outdated'
6
+ require 'bundler/cli/update'
7
+ require 'thor'
8
+ require 'json'
9
+ require 'open3'
10
+ require 'open3'
11
+ require 'etc'
12
+ require 'git'
13
+ require 'console'
14
+ require 'zeitwerk'
15
+
16
+ core_ext = "#{__dir__}/dependency_bumper/bundler"
17
+ loader = Zeitwerk::Loader.for_gem
18
+ loader.ignore(core_ext)
19
+ loader.setup
20
+
21
+ module DependencyBumper
22
+ end
23
+
24
+ loader.eager_load
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ class CLI::Outdated
5
+ def run
6
+ check_for_deployment_mode!
7
+
8
+ Bundler.definition.validate_runtime!
9
+ # this commands gets current gems
10
+ current_specs = Bundler.ui.silence { Bundler.definition.resolve }
11
+
12
+ current_dependencies = Bundler.ui.silence do
13
+ Bundler.load.dependencies.map { |dep| [dep.name, dep] }.to_h
14
+ end
15
+
16
+ definition = gems.empty? && sources.empty? ? Bundler.definition(true) : Bunder.definition(gems: gems, sources: sources)
17
+
18
+ Bundler::CLI::Common.configure_gem_version_promoter(
19
+ Bundler.definition,
20
+ options
21
+ )
22
+
23
+ options[:local] ? definition.resolve_with_cache! : definition.resolve_remotely!
24
+
25
+ # Loop through the current specs
26
+ gemfile_specs, dependency_specs = current_specs.partition do |spec|
27
+ current_dependencies.key? spec.name
28
+ end
29
+
30
+ specs = gemfile_specs + dependency_specs
31
+
32
+ specs.sort_by(&:name).each do |current_spec|
33
+ next unless gems.empty? || gems.include?(current_spec.name)
34
+
35
+ active_spec = retrieve_active_spec(definition, current_spec)
36
+ next unless active_spec
37
+
38
+ unless filter_options_patch.empty? || update_present_via_semver_portions(current_spec, active_spec, options)
39
+ next
40
+ end
41
+
42
+ gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
43
+ unless gem_outdated || (current_spec.git_version != active_spec.git_version)
44
+ next
45
+ end
46
+
47
+ dependency = current_dependencies[current_spec.name]
48
+
49
+ outdated_gems_list << {
50
+ active_spec: active_spec,
51
+ current_spec: current_spec,
52
+ dependency: dependency
53
+ }
54
+ end
55
+
56
+ return [] if outdated_gems_list.empty?
57
+
58
+ print_gems(outdated_gems_list)
59
+
60
+ outdated_gems_list
61
+ end
62
+
63
+ def print_gem(current_spec, active_spec, dependency)
64
+ spec_version = "#{active_spec.version}#{active_spec.git_version}"
65
+ if Bundler.ui.debug? && active_spec.loaded_from
66
+ spec_version += " (from #{active_spec.loaded_from})"
67
+ end
68
+ current_version = "#{current_spec.version}#{current_spec.git_version}"
69
+
70
+ if dependency&.specific?
71
+ dependency_version = %(, requested #{dependency.requirement})
72
+ end
73
+
74
+ spec_outdated_info = "#{active_spec.name} (newest #{spec_version}, " \
75
+ "installed #{current_version}#{dependency_version})"
76
+
77
+ output_message = spec_outdated_info.to_s
78
+
79
+ Bundler.ui.info output_message.rstrip
80
+ end
81
+
82
+ def print_gems(gems_list)
83
+ gems_list.each do |gem|
84
+ print_gem(*gem.values_at(:current_spec, :active_spec, :dependency))
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DependencyBumper
4
+ class Cli < Thor
5
+ DEFAULT_CONFIGURATION = {
6
+ 'skip' => {},
7
+ 'outdated_level' => 'strict',
8
+ 'update' => {
9
+ 'default' => 'minor',
10
+ 'major' => {},
11
+ 'minor' => {},
12
+ 'patch' => {}
13
+ },
14
+ 'git' => {
15
+ 'commit' => {
16
+ 'gpgsign' => false
17
+ }
18
+ }
19
+ }.freeze
20
+
21
+ package_name 'Dependency Bumper'
22
+
23
+ option :config, type: :string
24
+ option :git, type: :boolean
25
+ option :dry, type: :boolean
26
+ desc 'bump_gems', 'update dependencies of your Ruby project'
27
+ long_desc <<-LONGDESC
28
+ `bump_gems` will update dependencies of your Ruby project
29
+
30
+ If you give --git option it will create a branch and commit message will include information about updated gems.
31
+
32
+ --dry option will change Gemfile.lock but won't install gems.
33
+
34
+ This gem looks for a config file called bumper_config.json by default and if it doesn't find it, it will use default
35
+
36
+ configuration. You can point out another folder for configuration.
37
+
38
+ Examples \n
39
+ > $ dbump bump_gems --git --config myconfig.json \n
40
+ > $ dbump bump_gems --dry \n
41
+ > $ dbump bump_gems \n
42
+
43
+ LONGDESC
44
+
45
+ def bump_gems
46
+ path = options.fetch(:config, '.bumper_config.json')
47
+ Updater.new(load_config(Pathname.new(path)), options.slice(:dry, :git)).run
48
+ end
49
+
50
+ private
51
+
52
+ def load_config(config_file)
53
+ return JSON.parse(config_file.read) if config_file.exist?
54
+
55
+ Console.logger.info("Couldn\'t find #{config_file} file, falling back to default values")
56
+ DEFAULT_CONFIGURATION
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,196 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dependency_bumper/bundler/cli/outdated'
4
+
5
+ module DependencyBumper
6
+ class Updater
7
+ attr_reader :config, :cmd_ln_opt, :report
8
+
9
+ def initialize(config, cmd_ln_opt)
10
+ @config = config
11
+ @cmd_ln_opt = cmd_ln_opt
12
+ end
13
+
14
+ def run
15
+ gem_list = outdated_gems
16
+ return if gem_list == []
17
+
18
+ commands = generate_update_arguments(gem_list)
19
+ options = { 'jobs' => Etc.nprocessors }
20
+
21
+ @report = report_result do
22
+ commands.each do |group, gems|
23
+ Bundler.settings.temporary(no_install: cmd_ln_opt.fetch(:dry, false)) do
24
+ Bundler::CLI::Update.new(options.merge({ group => true }), gems).run
25
+ end
26
+ end
27
+ end
28
+
29
+ if report.empty?
30
+ Console.logger.info('No gem updated')
31
+ else
32
+ Console.logger.info(report)
33
+ create_git_branch(report) if cmd_ln_opt.fetch(:git, false)
34
+ end
35
+ end
36
+
37
+ def create_git_branch(report)
38
+ branch_name = "gem-bump-#{Time.now.strftime('%d-%m-%Y')}"
39
+ repo_path = exec(['git', 'rev-parse', '--show-toplevel']).first.strip
40
+ git_repo = Git.open(repo_path, log: Console.logger)
41
+
42
+ git_config_username_email(git_repo)
43
+ git_repo.checkout(branch_name, new_branch: true)
44
+
45
+ output = <<~END
46
+ Updating gems #{Time.now.strftime('%d-%m-%Y')}
47
+ #{report}
48
+ END
49
+
50
+ git_repo.add(all: true)
51
+ git_repo.commit(output)
52
+ rescue Git::GitExecuteError => e
53
+ Console.logger.error(e)
54
+ end
55
+
56
+ def git_config_username_email(repo)
57
+ if repo.config['user.email'].nil? || repo.config['user.name'].nil?
58
+ Console.logger.info('Setting up temporary username and email for committing please update git config')
59
+ repo.config('user.name', 'Your name')
60
+ repo.config('user.email', 'you@example.com')
61
+ else
62
+ Console.logger.info('User name and email is set, read to commit')
63
+ end
64
+ repo.config('commit.gpgsign', config.dig('git', 'commit', 'gpgsign').to_s)
65
+ end
66
+
67
+ def report_result
68
+ master_lockfile = Bundler::LockfileParser.new(Bundler.read_file(current_gem_file))
69
+
70
+ gems = {}
71
+
72
+ master_lockfile.specs.each do |spec|
73
+ gems[spec.name] = { from: spec.version }
74
+ end
75
+
76
+ yield
77
+
78
+ updated_lockfile = Bundler::LockfileParser.new(Bundler.read_file(current_gem_file))
79
+
80
+ updated_lockfile.specs.each do |spec|
81
+ gems[spec.name][:to] = spec.version if gems[spec.name]
82
+ end
83
+
84
+ output = ''
85
+ gems.each do |k, v|
86
+ next if v[:from] == v[:to]
87
+
88
+ message = "#{k} From #{v[:from]} To #{v[:to]} update level: #{major_minor_patch(v[:from], v[:to])} \n"
89
+ output += message
90
+ end
91
+
92
+ output
93
+ end
94
+
95
+ def major_minor_patch(old_version, new_version)
96
+ old_versions = old_version.canonical_segments
97
+ new_versions = new_version.canonical_segments
98
+
99
+ if new_versions[0] - old_versions[0] > 1
100
+ return :major
101
+ else # check cases like 1.9 to 2.0
102
+ return :major if new_versions[1].nil? || new_versions[1].nil?
103
+
104
+ return :minor if new_versions[1] < old_versions[1]
105
+ end
106
+
107
+ if new_versions[1] - old_versions[1] > 1
108
+ return :minor
109
+ else
110
+ return :patch if new_versions[2].nil? || new_versions[2].nil?
111
+
112
+ return :patch if new_versions[2] < old_versions[2]
113
+ end
114
+
115
+ return :patch if new_versions[2] - old_versions[2] >= 1
116
+ end
117
+
118
+ private
119
+
120
+ def current_gem_file
121
+ Bundler::SharedHelpers.default_lockfile
122
+ end
123
+
124
+ def outdated_gems
125
+ bundler = Bundler::CLI::Outdated.new({ convert_outdated_level => true, parseable: true }, [])
126
+ outdated_gems_list = bundler.run
127
+
128
+ if outdated_gems_list == []
129
+ Console.logger.info('No outdated gems found')
130
+ return []
131
+ end
132
+
133
+ outdated_gems_list.map { |gem| gem[:current_spec].name }
134
+ end
135
+
136
+ def convert_outdated_level
137
+ {
138
+ 'strict' => 'filter-strict',
139
+ 'patch' => 'filer-patch',
140
+ 'minor' => 'filter-minor',
141
+ 'major' => 'filter-major',
142
+ }.fetch(config['outdated_level'], 'filter-strict')
143
+ end
144
+
145
+ def exec(cmd)
146
+ result = []
147
+ Open3.popen3(*cmd) do |_, stdout, stderr, wait_thr|
148
+ stdout.each_line do |x|
149
+ Console.logger.info(x)
150
+
151
+ next if x.match?(/^\n$/)
152
+
153
+ result << x
154
+ end
155
+
156
+ stderr.each do |x|
157
+ Console.logger.error(x)
158
+ end
159
+
160
+ exit_status = wait_thr.value # Process::Status object returned.
161
+ Console.logger.debug("exit status: #{exit_status.success?}")
162
+ end
163
+
164
+ result
165
+ end
166
+
167
+ def generate_update_arguments(gem_names)
168
+ grouped_gems = {
169
+ 'major' => [],
170
+ 'minor' => [],
171
+ 'patch' => [],
172
+ }
173
+
174
+ gem_names.each do |gem_name|
175
+ next if config['skip'].key?(gem_name)
176
+
177
+ placed_in_group = false
178
+
179
+ grouped_gems.keys.each do |group_name|
180
+ if config['update'][group_name].key?(gem_name)
181
+ grouped_gems[group_name] << gem_name
182
+ placed_in_group = true
183
+ end
184
+ end
185
+
186
+ unless placed_in_group
187
+ grouped_gems[config['update']['default']] << gem_name
188
+ end
189
+ end
190
+
191
+ grouped_gems.reject! { |_, v| v.empty? }
192
+
193
+ grouped_gems
194
+ end
195
+ end
196
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DependencyBumper
4
+ VERSION = '0.1.0'
5
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dependency_bumper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Can Eldem
8
+ - Mo Khan
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2020-09-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: git
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.7'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.7'
28
+ - !ruby/object:Gem::Dependency
29
+ name: thor
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.19'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.19'
42
+ - !ruby/object:Gem::Dependency
43
+ name: byebug
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '11.1'
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 11.1.3
52
+ type: :development
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - "~>"
57
+ - !ruby/object:Gem::Version
58
+ version: '11.1'
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 11.1.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: console
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.8'
76
+ - !ruby/object:Gem::Dependency
77
+ name: bundler
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.1'
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.1'
90
+ - !ruby/object:Gem::Dependency
91
+ name: zeitwerk
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.3'
97
+ type: :runtime
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.3'
104
+ description:
105
+ email:
106
+ - eldemcan@gmail.com
107
+ - mo@mokhan.ca
108
+ executables:
109
+ - dbump
110
+ extensions: []
111
+ extra_rdoc_files: []
112
+ files:
113
+ - ".github/workflows/gem-push.yml"
114
+ - ".github/workflows/ruby.yml"
115
+ - ".gitignore"
116
+ - ".rspec"
117
+ - ".rubocop.yml"
118
+ - ".travis.yml"
119
+ - CHANGELOG.md
120
+ - CODE_OF_CONDUCT.md
121
+ - Dockerfile
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - bin/console
129
+ - bin/setup
130
+ - dependency_bumper.gemspec
131
+ - exe/dbump
132
+ - lib/dependency_bumper.rb
133
+ - lib/dependency_bumper/bundler/cli/outdated.rb
134
+ - lib/dependency_bumper/cli.rb
135
+ - lib/dependency_bumper/updater.rb
136
+ - lib/dependency_bumper/version.rb
137
+ homepage: https://github.com/spandx/dependency_bumper
138
+ licenses:
139
+ - Apache-2.0
140
+ metadata:
141
+ homepage_uri: https://github.com/spandx/dependency_bumper
142
+ source_code_uri: https://github.com/spandx/dependency_bumper
143
+ changelog_uri: https://github.com/spandx/dependency_bumper
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 2.3.0
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubygems_version: 3.0.3
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: Tool helps you to automate updating dependencies of your Ruby project.
163
+ test_files: []