strong_versions

Public
Set up and enforce strong versioning in the Gemfile
Icons/chart bar
Used 12 times
Created by
T TobiasBales

Usage

Run this command in your Rails app directory in the terminal:

rails app:template LOCATION="https://railsbytes.com/script/zl0s0Q"
Template Source

Review the code before running this template on your machine.

def create_bin(name, command = nil)
  create_file "bin/#{name}" do <<~EOF
    #!/usr/bin/env ruby
    APP_ROOT = File.expand_path('..', __dir__)
    Dir.chdir(APP_ROOT) do
      begin
        exec '#{command || name}'
      rescue Errno::ENOENT
        $stderr.puts "#{name} executable was not detected in the system."
        exit 1
      end
    end
  EOF
  end
  `chmod +x bin/#{name}`
end

gsub_file 'Gemfile', "'tzinfo-data'", "'tzinfo-data', '~> 1.2'"

gem_group :development do
  gem 'strong_versions'
end

Bundler.with_unbundled_env { run 'bundle install' }

create_bin 'strong_versions'
create_bin 'strong_versions_fix', 'strong_versions --auto-correct'

system('bin/strong_versions_fix')
Comments

Sign up or Login to leave a comment.