Flowdock
method

append_dependencies_to_package_file

Importance_0
v6.1.7.7 - Show latest stable - 0 notes - Class: InstallGenerator
  • 1.0.0
  • 1.1.6
  • 1.2.6
  • 2.0.3
  • 2.1.0
  • 2.2.1
  • 2.3.8
  • 3.0.0
  • 3.0.9
  • 3.1.0
  • 3.2.1
  • 3.2.8
  • 3.2.13
  • 4.0.2
  • 4.1.8
  • 4.2.1
  • 4.2.7
  • 4.2.9
  • 5.0.0.1
  • 5.1.7
  • 5.2.3
  • 6.0.0
  • 6.1.3.1 (0)
  • 6.1.7.7 (0)
  • 7.0.0
  • 7.1.3.2
  • What's this?
append_dependencies_to_package_file() public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File actiontext/lib/generators/action_text/install/install_generator.rb, line 19
      def append_dependencies_to_package_file
        if (app_javascript_pack_path = Pathname.new("app/javascript/packs/application.js")).exist?
          js_dependencies.each_key do |dependency|
            line = %[require("#{dependency}")]

            unless app_javascript_pack_path.read.include? line
              say "Adding #{dependency} to #{app_javascript_pack_path}", :green
              append_to_file app_javascript_pack_path, "\n#{line}"
            end
          end
        else
          say <<~WARNING, :red
            WARNING: Action Text can't locate your JavaScript bundle to add its package dependencies.

            Add these lines to any bundles:

            require("trix")
            require("@rails/actiontext")

            Alternatively, install and setup the webpacker gem then rerun `bin/rails action_text:install`
            to have these dependencies added automatically.
          WARNING
        end
      end

      def create_actiontext_files
        template "actiontext.scss", "app/assets/stylesheets/actiontext.scss"

        copy_file "#{GEM_ROOT}/app/views/active_storage/blobs/_blob.html.erb",
          "app/views/active_storage/blobs/_blob.html.erb"
      end

      def create_migrations
        rails_command "railties:install:migrations FROM=active_storage,action_text", inline: true
      end

      hook_for :test_framework

      private
        GEM_ROOT = "#{__dir__}/../../../.."

        def js_dependencies
          js_package = JSON.load(Pathname.new("#{GEM_ROOT}/package.json"))
          js_package["peerDependencies"].merge \            js_package["name"] => "^#{js_package["version"]}"
        end
    end
  end
end
Register or log in to add new notes.