Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Validate that a plugin adds commands, overrides, or both, but fails i…
Browse files Browse the repository at this point in the history
…f it has neither.

Signed-off-by: Gene Johnston <Eugene.Johnston@ca.com>
  • Loading branch information
Gene Johnston authored and Gene Johnston committed Sep 17, 2018
1 parent ca28135 commit e2d4236
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions packages/imperative/src/plugins/PluginManagementFacility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,16 @@ export class PluginManagementFacility {
".pluginHealthCheck' property does not exist: " + healthChkFilePath);
}
}
if (!pluginCmdGroup.children || pluginCmdGroup.children.length <= 0) {

/* If a plugin does neither of the following actions, we reject it:
* - define commands
* - override an infrastructure component
*/
if ((!pluginCmdGroup.children || pluginCmdGroup.children.length <= 0) &&
(!pluginCfgProps.impConfig.overrides || Object.keys(pluginCfgProps.impConfig.overrides).length <= 0))
{
this.pluginIssues.recordIssue(pluginCfgProps.pluginName, IssueSeverity.ERROR,
"The plugin's configuration defines no children.");
"The plugin defines no commands and overrides no framework components.");
} else {
// recursively validate the plugin's command definitions
this.validatePluginCmdDefs(pluginCfgProps.pluginName, pluginCmdGroup.children);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class ValidateHandler implements ICommandHandler {
let msgColor: string = "yellow";
if (this.pluginIssues.doesPluginHaveError(pluginName)) {
msgColor = "red";
valResultsMsg += "No commands from this plugin will be available for future commands.\n";
valResultsMsg += "No operations from this plugin will be available for future commands.\n";
}

cmdResponse.console.log(TextUtils.chalk[msgColor](valResultsMsg));
Expand Down

0 comments on commit e2d4236

Please sign in to comment.