Sha256: d6a23fa20f0f0f326ab1f5b2e39362a60331910483b8759b548d0824fc2973e5

Contents?: true

Size: 1018 Bytes

Versions: 2

Compression:

Stored size: 1018 Bytes

Contents

module JetsUpgrade
  class Javascript
    def run
      Remove.run
      Move.run
      Gitignore.run
      rewrite_view_js
    end

    def rewrite_view_js
      changed = false
      Dir.glob("app/views/**/*").each do |path|
        next if File.directory?(path)
        changed ||= JetsUpgrade::Rewrite::ViewJs.new(path).run
      end
      puts note if changed
    end

    def note
      puts <<~EOL
        Rewrote files use javascript_include_tag and stylesheet_link_tag instead of javascript_pack_tag and stylesheet_pack_tag.
        Please double check the file to make sure it looks correct.

        This does not take you all the way to importmaps. It just gets rid of the webpacker logic.
        More info: https://rubyonjets.com/docs/assets/importmap/
        To set up importmaps, please run:

      EOL
      puts "    jets importmap:install".color(:green)
      puts
      puts "Note: If they are conflicts, you can probably overwrite them."
    end

    def self.run
      new.run
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jets-upgrade-0.1.1 lib/jets_upgrade/javascript.rb
jets-upgrade-0.1.0 lib/jets_upgrade/javascript.rb