mixmaxhq/custody

Add CLI command to install a new plugin

wearhere opened this issue · 1 comments

custody-cli install <plugin package name> should

  1. npm install the plugin
  2. add the plugin to custody settings, by which I mean, at minimum, adding the name of the plugin to the "plugins" array.

Post-install setup

A wrinkle in step 2 above is that some plugins like @custody/plugin-log-notifier require additional arguments in settings (patterns has no default here). Some thoughts on how to handle this:

Without doing anything

We let the user observe that the plugin isn't working and check custody's logs, in which case they would see an error (thrown here) and go check the plugin's README to fix it.

Placeholder settings

We make it possible for plugins to export "placeholder settings", to write into custody's settings, e.g. in the case of @custody/plugin-log-notifier maybe we have that plugin do

module.exports = function() { /* the plugin definition */ };
module.exports.settings = {
  patterns: []
};

Other ways of doing this without messing with module.exports would be to optionally define settings.json file in the root of the plugin, or put the settings under some new field in the plugin's package.json.

Either way, the contents of settings(.json) would get written into custody settings like

{
  "plugins": [
    ["@custody/plugin-log-notifier", {
      "patterns": [],
    }]
  ]
}

Although this is still not functional (just suppresses the error)—the user has to fill that array out. (If an empty array would truly suffice, the plugin could have just made that a default argument here.)

So, to get the user to fill that out, custody-cli install might:

  1. if it discovers any settings on installation
  2. print a message saying "One or more plugins require post-install setup. Open settings to finish installation?"
  3. And then if the user says yes, pop custody-cli settings like previous.

There's probably an opportunity for plugins to provide (a link to) setup instructions in tandem with, or in place of, the "placeholder settings" idea above.