Class: Heroku::Command::Plugins

Inherits:
Base
  • Object
show all
Defined in:
lib/heroku/command/plugins.rb

Overview

manage plugins to the heroku gem

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#api, #app, #heroku, #initialize, namespace, #org, #org_api

Methods included from Helpers

#action, #app_owner, #ask, #confirm, #confirm_command, #create_git_remote, #debug, #debugging?, #default_org_host, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #error, #error_log, #error_log_path, error_with_failure, error_with_failure=, extended, extended_into, #fail, #format_bytes, #format_date, #format_error, #format_with_bang, #get_terminal_environment, #git, #has_git?, #has_git_remote?, #has_http_git_entry_in_netrc, #home_directory, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #launchy, #line_formatter, #longest, #org?, #org_host, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #stderr_print, #stderr_puts, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #time_ago, #truncate, #update_git_remote, #warn_if_using_jruby, #with_tty

Constructor Details

This class inherits a constructor from Heroku::Command::Base

Instance Method Details

#indexObject

plugins

list installed plugins

Example:

$ heroku plugins

Installed Plugins

[email protected]


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/heroku/command/plugins.rb', line 18

def index
  validate_arguments!

  plugins = ::Heroku::JSPlugin.plugins.map { |p| "#{p[:name]}@#{p[:version]}" }
  plugins.concat(::Heroku::Plugin.list)

  if plugins.length > 0
    styled_header("Installed Plugins")
    styled_array(plugins)
  else
    display("You have no installed plugins.")
  end
end

#installObject

plugins:install URL

install a plugin

Example:

$ heroku plugins:install heroku-production-check Installing heroku-production-check… done


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/heroku/command/plugins.rb', line 41

def install
  name = shift_argument
  validate_arguments!
  if name =~ /\./    # if it contains a '.' then we are assuming it is a URL
    # and we should install it as a ruby plugin

    ruby_plugin_install(name)
  else
    js_plugin_install(name)
  end
end

#uninstallObject

plugins:uninstall PLUGIN

uninstall a plugin

Example:

$ heroku plugins:uninstall heroku-production-check Uninstalling heroku-production-check… done


62
63
64
65
66
67
68
69
70
71
72
# File 'lib/heroku/command/plugins.rb', line 62

def uninstall
  plugin = Heroku::Plugin.new(shift_argument)
  validate_arguments!
  if Heroku::Plugin.list.include? plugin.name
    action("Uninstalling #{plugin.name}") do
      plugin.uninstall
    end
  elsif Heroku::JSPlugin.setup?
    Heroku::JSPlugin.uninstall(plugin.name)
  end
end

#updateObject

plugins:update [PLUGIN]

updates all plugins or a single plugin by name

Example:

$ heroku plugins:update Updating heroku-production-check… done

$ heroku plugins:update heroku-production-check Updating heroku-production-check… done


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/heroku/command/plugins.rb', line 86

def update
  plugins = if plugin = shift_argument
    [plugin]
  else
    ::Heroku::Plugin.list
  end
  validate_arguments!

  plugins.each do |plugin|
    begin
      action("Updating #{plugin}") do
        begin
          Heroku::Plugin.new(plugin).update
        rescue Heroku::Plugin::ErrorUpdatingSymlinkPlugin
          status "skipped symlink"
        end
      end
    rescue SystemExit      # ignore so that other plugins still update

    end
  end
end