Skip to content

Commit

Permalink
Create a placeholder version of the gem to warn against the unbounded…
Browse files Browse the repository at this point in the history
… Rubocop dependency of <=0.0.36

This defines a v0.0.36.1 which we will tag and publish so that when future users add `standard` to a Gemfile that resolves a newer version of rubocop (directly or indirectly), it will at least warn them at postinstall and on each CLI invocation of what's going on.

Decided to exit instead of run the CLI, because it's easy to lose the message in all the warnings that will be printed by the (way too new) version of RuboCop that will likely be loaded by the configuration builder
  • Loading branch information
searls committed Apr 5, 2023
1 parent 96a9d5a commit 43c58be
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 26 deletions.
37 changes: 19 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
PATH
remote: .
specs:
standard (0.0.36)
rubocop (>= 0.63)
standard (0.0.36.1)
rubocop (> 0.63)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.0)
ast (2.4.2)
coderay (1.1.2)
docile (1.3.1)
gimme (0.5.0)
jaro_winkler (1.5.2)
json (2.1.0)
method_source (0.9.2)
minitest (5.11.3)
parallel (1.14.0)
parser (2.6.0.0)
ast (~> 2.4.0)
powerpack (0.1.2)
parallel (1.22.1)
parser (3.2.2.0)
ast (~> 2.4.1)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
psych (3.1.0)
rainbow (3.0.0)
rainbow (3.1.1)
rake (12.3.2)
rubocop (0.65.0)
jaro_winkler (~> 1.5.1)
regexp_parser (2.7.0)
rexml (3.2.5)
rubocop (1.31.0)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
psych (>= 3.1.0)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.18.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.4.0)
ruby-progressbar (1.10.0)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.28.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
unicode-display_width (1.4.1)
unicode-display_width (2.4.2)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ No decisions to make. It just works. Here's a [⚡ lightning talk ⚡](https://w
Install by adding it to your Gemfile:

```ruby
gem "standard", group: [:development, :test]
gem "standard", ">= 1.0", group: [:development, :test]
```

And running `bundle install`.
Expand Down
8 changes: 3 additions & 5 deletions lib/standard/cli.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require_relative "builds_config"
require_relative "loads_runner"
require_relative "prints_big_hairy_version_warning"

module Standard
class Cli
Expand All @@ -13,11 +14,8 @@ def initialize(argv)
end

def run
config = @builds_config.call(@argv)

success = @loads_runner.call(config.runner).call(config)

success ? SUCCESS_STATUS_CODE : FAILURE_STATUS_CODE
PrintsBigHairyVersionWarning.new.call
exit 1
end
end
end
48 changes: 48 additions & 0 deletions lib/standard/prints_big_hairy_version_warning.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module Standard
class PrintsBigHairyVersionWarning
WARNING = <<~MSG.gsub(/^ {6}/, "")
============================================================================
= WARNING: You do not want to run this very, very old version of Standard! =
============================================================================
What's going on here?
---------------------
Versions of Standard prior to 0.0.37 depended on `>= 0.63' of RuboCop, which
means that Bundler continues to resolve to those (now ancient) versions
whenever `gem "standard"' is added to a Gemfile that has already locked
to a newer version of RuboCop than standard currently depends on.
"How do I fix this?", you might be asking.
How to fix this
---------------
If you add a version specifier pinning `standard' to a version newer
than 0.0.36.1, Bundler will resolve appropriate versions of `standard',
`rubocop', and any other rubocop-dependent gems you may have installed.
1. Update your Gemfile to pin standard to be at least one such version:
gem "standard", ">= 1.0"
2. Run `bundle`, which will install and lock more appropriate versions
Example output:
Using rubocop 1.48.1 (was 1.49.0)
Using rubocop-performance 1.16.0
Using standard 1.26.0 (was 0.0.36)
This version (0.0.36.1) is an inoperative placeholder gem that exists
solely to print this message.
We're very sorry for this inconvenience!
============================================================================
= END OF BIG SCARY WARNING =
============================================================================
MSG

def call
warn WARNING
end
end
end
2 changes: 1 addition & 1 deletion lib/standard/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Standard
VERSION = Gem::Version.new("0.0.36")
VERSION = Gem::Version.new("0.0.36.1")
end
5 changes: 4 additions & 1 deletion standard.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "standard/version"
require "standard/prints_big_hairy_version_warning.rb"

Gem::Specification.new do |spec|
spec.name = "standard"
Expand All @@ -18,7 +19,9 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "rubocop", ">= 0.63"
spec.add_dependency "rubocop", "> 0.63"

spec.post_install_message = Standard::PrintsBigHairyVersionWarning::WARNING

spec.add_development_dependency "bundler", "~> 1.17"
spec.add_development_dependency "minitest", "~> 5.0"
Expand Down

0 comments on commit 43c58be

Please sign in to comment.