Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI command to install a new plugin #86

Open
wearhere opened this issue Nov 26, 2019 · 1 comment
Open

Add CLI command to install a new plugin #86

wearhere opened this issue Nov 26, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@wearhere
Copy link
Contributor

wearhere commented Nov 26, 2019

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.
@wearhere
Copy link
Contributor Author

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.

@wearhere wearhere added the enhancement New feature or request label Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant