jmcdo29/nest-commander

Allow for "decentralized" commands

Closed this issue · 2 comments

If someone wants to have commands that are "project oriented" (examples being specialized configuration setups, seeding, initialization processes, etc) it is currently not clear to me on how to have a CLI package that can be global and at the same time, use local dependencies.

This is a request to have the ability to run local "packaged" commands within a project, but via a globally installed CLI (also built with Nest-Commander). In this way, the local commands can be developed in pace with the project and stay in sync, whereas the global CLI can be on a totally different development track.

I hope that made sense.

Scott

Okay, so here's my thought: we add in a new flag in the CommandFactory like usePlugins. When this is true, the command factory will read through a nest-commander.json file (or named something else via config configFileName, definitely make it rc compliant) and it will read for plugins, which will be an array of package names. These packages just need to export a Nest module that has a command in the providers array. Then, the Factory will add these plugins to the root module's imports and they will be available. These plugins will need to be installed via npm, or if it's a link, it needs to work via require (or import if we go with esm support)

If there base command is built with usePlugins and there's no config file, throw an error along the lines of

<CLI Name> is expecting to use plugins, but no configuration file for plugins found. Are you in the right directory?
<pwd>

closed by #67. Available in 2.3.0