Class: Wabi::Generators::ListGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/wabi/generators/list_generator.rb

Instance Method Summary collapse

Instance Method Details

#listObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/wabi/generators/list_generator.rb', line 12

def list
  lockfile = Wabi::Lockfile.load(File.join(destination_root, "config/wabi.lock.json"))
  installed_names = lockfile.components.keys

  client = Wabi::RegistryClient.new(base_url: lockfile.registry)
  catalog = client.fetch("index")["components"] || []

  say "\nRegistry: #{lockfile.registry}\n", :cyan
  catalog.each do |entry|
    name = entry["name"]
    marker = installed_names.include?(name) ? "[installed]" : "          "
    say format("  %s  %-20s  v%s", marker, name, entry["version"])
  end
end