bundler-interactive 0.1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7cb83b26ff4dea18f9dcfb7c8aa94ca8b1a90ed6e87f6cf3350686e75d828dee
4
+ data.tar.gz: ca98b4c3abd8b9654341d960f19af1867f29fa87da2d3cb72620527d1fa9308d
5
+ SHA512:
6
+ metadata.gz: 618be7c402a08da7a0e4a46098b2aed18ec20dad968e3d34be05ed0192bbb90acbe90fd364bc6394ab5e2fe891d98917110c919195a9a147b45e63420c43168b
7
+ data.tar.gz: d4aa3d4202a94a0a555d315f46c34e44969c886d753864ae2097953f19c052c556c749df1cc221af737ab0e445a574ceec8a931e05fda51fe362e4ec097adb0b
@@ -0,0 +1,13 @@
1
+ Gemfile.lock
2
+
3
+ /.bundle/
4
+ /.yardoc
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,2 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
@@ -0,0 +1,26 @@
1
+ version: v1.0
2
+ name: Bundler::Interactive
3
+ agent:
4
+ machine:
5
+ type: e1-standard-2
6
+ os_image: ubuntu1804
7
+
8
+ blocks:
9
+ - name: Build
10
+ execution_time_limit:
11
+ minutes: 1
12
+ task:
13
+ jobs:
14
+ - name: Tests
15
+ matrix:
16
+ - env_var: RUBY_VERSION
17
+ values: ['2.3', '2.4', '2.5', '2.6.3']
18
+ commands:
19
+ - checkout
20
+ - sem-version ruby $RUBY_VERSION
21
+
22
+ # - cache restore gems-$RUBY_VERSION,gems-
23
+ # - bundle check --path=vendor/bundle || bundle install
24
+ # - cache store gems-$RUBY_VERSION vendor/bundle
25
+ - bundle install
26
+ - bundle exec rspec --format documentation
@@ -0,0 +1,9 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3
7
+ - 2.4
8
+ - 2.5
9
+ - 2.6
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in bundler-interactive.gemspec
6
+ gemspec
@@ -0,0 +1,24 @@
1
+ # Bundler::Interactive
2
+
3
+ This is a plugin to Bundler which provides an interactive interface to manage updating outdated gems within your project similar to [`yarn upgrade-interactive`]
4
+
5
+ ## Installation
6
+
7
+ $ bundle plugin install bundler-interactive
8
+
9
+ ## Usage
10
+
11
+ $ bundle update-interactive
12
+
13
+ ## Development
14
+
15
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
16
+
17
+ 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).
18
+
19
+ ## Contributing
20
+
21
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wesrich/bundler-interactive.
22
+
23
+
24
+ [`yarn upgrade-interactive`]: https://yarnpkg.com/lang/en/docs/cli/upgrade-interactive/
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bundler/interactive"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ 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,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'bundler/interactive/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'bundler-interactive'
9
+ spec.version = Bundler::Interactive::VERSION
10
+ spec.authors = ['Wes Rich']
11
+ spec.email = ['wes@wesrich.com']
12
+
13
+ spec.summary = 'Interactive prompt for Bundler'
14
+ spec.description = 'Interactive prompt for Bundler'
15
+ spec.homepage = 'https://github.com/wesrich/Bundler-Interactive'
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+
22
+ spec.metadata['homepage_uri'] = spec.homepage
23
+ spec.metadata['source_code_uri'] = spec.homepage
24
+ spec.metadata['changelog_uri'] = spec.homepage
25
+ else
26
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
27
+ 'public gem pushes.'
28
+ end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = 'exe'
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ['lib']
38
+
39
+ spec.required_ruby_version = '>= 2.3.0'
40
+
41
+ spec.add_development_dependency 'bundler', '>= 1.16'
42
+ spec.add_development_dependency 'rake', '~> 10.0'
43
+ spec.add_development_dependency 'rspec', '~> 3.0'
44
+
45
+ spec.add_dependency 'tty-prompt'
46
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dir.chdir(__dir__) do
4
+ Dir['interactive/*.rb'].each { |file| require_relative file }
5
+ end
6
+
7
+ module Bundler
8
+ module Interactive
9
+ class Error < StandardError; end
10
+ end
11
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ module Interactive
5
+ class OutdatedGem
6
+ VERSION_NAMES = %w[MAJOR MINOR PATCH].freeze
7
+
8
+ def initialize(current_spec, active_spec, dependency)
9
+ @current_spec = current_spec
10
+ @active_spec = active_spec
11
+ @dependency = dependency
12
+ end
13
+
14
+ def name(padding = 0)
15
+ current_spec.name.ljust(padding)
16
+ end
17
+
18
+ def current_version
19
+ current_spec.version
20
+ end
21
+
22
+ def active_version
23
+ active_spec.version
24
+ end
25
+
26
+ def label
27
+ "#{version_label.ljust(10)} " \
28
+ "newest #{active_version.to_s.ljust(10)} " \
29
+ "installed #{current_version.to_s.ljust(10)} " \
30
+ "#{dependency_text.ljust(20)}"
31
+ end
32
+
33
+ private
34
+
35
+ attr_reader :current_spec, :active_spec, :dependency
36
+
37
+ def dependency_text
38
+ dependency ? "requested #{dependency.requirement}" : ''
39
+ end
40
+
41
+ def version_label
42
+ index = version_diff_index
43
+ index ? VERSION_NAMES[index] : 'GIT'
44
+ end
45
+
46
+ def version_diff_index
47
+ active_version
48
+ .segments
49
+ .zip(current_version.segments)
50
+ .index do |active_segment, current_segment|
51
+ active_segment.to_i > current_segment.to_i
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ module Interactive
5
+ class Update
6
+ attr_reader :gems
7
+
8
+ def initialize(gems)
9
+ @gems = gems
10
+ end
11
+
12
+ def update!
13
+ puts "Updating #{gems.join(', ')}..."
14
+ # Update Gemfile?
15
+ definition = Bundler.definition(gems: gems)
16
+ Bundler::Installer.install(Bundler.root, definition)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require 'tty-prompt'
5
+ rescue LoadError
6
+ # tty-prompt probably wasn't loaded when we tried to install the plugin
7
+ # for now, this is fine
8
+ nil
9
+ end
10
+
11
+ module Bundler
12
+ module Interactive
13
+ class UpdateInteractive < Bundler::Plugin::API
14
+ def exec(_command, _args)
15
+ response = prompt.multi_select(
16
+ 'Select one or more gems to update:', outdated_gem_list,
17
+ echo: false, per_page: 20, filter: true, cycle: true
18
+ )
19
+ Update.new(response).update! if response.any?
20
+ rescue TTY::Reader::InputInterrupt
21
+ prompt.say('Canceling...')
22
+ end
23
+
24
+ def outdated_gem_list
25
+ outdated_gems.map do |gem|
26
+ {
27
+ name: "#{gem.name(name_padding)} #{gem.label}",
28
+ value: gem.name
29
+ }
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def prompt
36
+ @prompt ||= TTY::Prompt.new
37
+ end
38
+
39
+ def outdated_gems
40
+ @outdated_gems ||= begin
41
+ current_gems
42
+ .sort_by(&:name)
43
+ .each_with_object([]) do |current_spec, outdated|
44
+ active_spec = definition.find_resolved_spec(current_spec)
45
+ next unless gem_outdated?(current_spec, active_spec)
46
+
47
+ outdated << OutdatedGem.new(current_spec, active_spec, dependencies[current_spec.name])
48
+ end
49
+ end
50
+ end
51
+
52
+ def current_gems
53
+ @current_gems ||= Bundler.definition.tap(&:validate_runtime!).resolve
54
+ end
55
+
56
+ def definition
57
+ @definition ||= Bundler.definition(true).tap(&:resolve_remotely!)
58
+ end
59
+
60
+ def dependencies
61
+ @dependencies ||=
62
+ Bundler.load.dependencies.map { |dep| [dep.name, dep] }.to_h
63
+ end
64
+
65
+ def gem_outdated?(current_spec, active_spec)
66
+ active_spec.version > current_spec.version ||
67
+ active_spec.git_version != current_spec.git_version
68
+ rescue NoMethodError
69
+ puts "Gem #{current_spec.name}, couldn't find an active_spec"
70
+ end
71
+
72
+ def name_padding
73
+ @name_padding ||= outdated_gems.map { |gem| gem.name.length }.max
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bundler
4
+ module Interactive
5
+ VERSION = '0.1.2.1'
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/interactive'
4
+
5
+ Bundler::Plugin::API.command(
6
+ 'update-interactive', Bundler::Interactive::UpdateInteractive
7
+ )
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bundler-interactive
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Wes Rich
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-08-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-prompt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Interactive prompt for Bundler
70
+ email:
71
+ - wes@wesrich.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".rubocop.yml"
79
+ - ".semaphore/semaphore.yml"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - bundler-interactive.gemspec
87
+ - lib/bundler/interactive.rb
88
+ - lib/bundler/interactive/outdated_gem.rb
89
+ - lib/bundler/interactive/update.rb
90
+ - lib/bundler/interactive/update_interactive.rb
91
+ - lib/bundler/interactive/version.rb
92
+ - plugins.rb
93
+ homepage: https://github.com/wesrich/Bundler-Interactive
94
+ licenses: []
95
+ metadata:
96
+ allowed_push_host: https://rubygems.org
97
+ homepage_uri: https://github.com/wesrich/Bundler-Interactive
98
+ source_code_uri: https://github.com/wesrich/Bundler-Interactive
99
+ changelog_uri: https://github.com/wesrich/Bundler-Interactive
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 2.3.0
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubygems_version: 3.0.4
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Interactive prompt for Bundler
119
+ test_files: []