Sha256: ef6943cb3e42f4a9e2a0a4c8b69257dc2f4c68e96dd7425ad08150796d210472

Contents?: true

Size: 1.52 KB

Versions: 7

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require "cable_ready/installer"

spring_pattern = /^[^#]*gem ["']spring["']/

proceed = false
lines = gemfile_path.readlines

if lines.index { |line| line =~ spring_pattern }
  proceed = if options.key? "spring"
    options["spring"]
  else
    !no?("✨ Would you like to disable the spring gem? \nIt's been removed from Rails 7, and is the frequent culprit behind countless mystery bugs. (Y/n)")
  end
else
  say "⏩ Spring is not installed."
end

if proceed
  spring_watcher_pattern = /^[^#]*gem ["']spring-watcher-listen["']/
  bin_rails_pattern = /^[^#]*load File.expand_path\("spring", __dir__\)/

  if (index = lines.index { |line| line =~ spring_pattern })
    remove_gem :spring

    bin_spring = Rails.root.join("bin/spring")
    if bin_spring.exist?
      run "bin/spring binstub --remove --all"
      say "✅ Removed spring binstubs"
    end

    bin_rails = Rails.root.join("bin/rails")
    bin_rails_content = bin_rails.readlines
    if (index = bin_rails_content.index { |line| line =~ bin_rails_pattern })
      backup(bin_rails) do
        bin_rails_content[index] = "# #{bin_rails_content[index]}"
        bin_rails.write bin_rails_content.join
      end
      say "✅ Removed spring from bin/rails"
    end
    create_file "tmp/cable_ready_installer/kill_spring", verbose: false
  else
    say "✅ spring has been successfully removed"
  end

  if lines.index { |line| line =~ spring_watcher_pattern }
    remove_gem "spring-watcher-listen"
  end
else
  say "⏩ Skipping."
end

complete_step :spring

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cable_ready-5.0.3 lib/install/spring.rb
cable_ready-5.0.2 lib/install/spring.rb
cable_ready-5.0.1 lib/install/spring.rb
cable_ready-5.0.0 lib/install/spring.rb
cable_ready-5.0.0.rc2 lib/install/spring.rb
cable_ready-5.0.0.rc1 lib/install/spring.rb
cable_ready-5.0.0.pre10 lib/install/spring.rb