Sha256: ebb678d8e994c3d0135b78fd11d5d3b4c7bf1e06114a2608eae358d842f629ed

Contents?: true

Size: 764 Bytes

Versions: 4

Compression:

Stored size: 764 Bytes

Contents

require "thor"
require "importmap/pinner"

class Importmap::Commands < Thor
  desc "pin [*PACKAGES]", "Pin new packages"
  option :env, type: :string, aliases: :e, default: "production"
  option :from, type: :string, aliases: :f, default: "jspm"
  def pin(*packages)
    if imports = Importmap::Pinner.new.pin(*packages, env: options[:env], from: options[:from])
      imports.each do |package, url|
        puts "Pinned '#{package}' to #{url}"
      end
    else
      puts "Couldn't find any packages in #{packages.inspect} on #{options[:provider]}"
    end
  end

  desc "json", "Show the full importmap in json"
  def json
    puts Rails.application.config.importmap.to_json(resolver: ActionController::Base.helpers)
  end
end

Importmap::Commands.start(ARGV)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
importmap-rails-0.4.3 lib/importmap/commands.rb
importmap-rails-0.4.2 lib/importmap/commands.rb
importmap-rails-0.4.1 lib/importmap/commands.rb
importmap-rails-0.4.0 lib/importmap/commands.rb