From 07e52e6adc8fe154a23a78b0c8e1ef516cec303f Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Thu, 11 Jan 2024 14:08:15 -0500 Subject: [PATCH] Improve CLI arguments --- .../kbn-plugin-check/dependencies/index.ts | 16 ++++++---------- packages/kbn-plugin-check/index.ts | 19 ++++++------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/packages/kbn-plugin-check/dependencies/index.ts b/packages/kbn-plugin-check/dependencies/index.ts index 64b4fc34e9a7d..5a77c64c25bc4 100644 --- a/packages/kbn-plugin-check/dependencies/index.ts +++ b/packages/kbn-plugin-check/dependencies/index.ts @@ -29,23 +29,19 @@ export const checkDependencies = (flags: Flags, log: ToolingLog) => { displayDependencyCheck(project, plugin, log); }; - const pluginName = flags.plugin && typeof flags.plugin === 'string' ? flags.plugin : null; - const teamName = flags.team && typeof flags.team === 'string' ? flags.team : null; + const pluginOrTeam = typeof flags.dependencies === 'string' ? flags.dependencies : undefined; - if ((!pluginName && !teamName) || (pluginName && teamName)) { - log.error(`Must specify plugin or team name.`); + if (!pluginOrTeam) { return; } - if (pluginName) { - checkPlugin(pluginName); - } - - if (teamName) { - const plugins = findTeamPlugins(teamName); + if (pluginOrTeam.startsWith('@elastic/')) { + const plugins = findTeamPlugins(pluginOrTeam); plugins.forEach((plugin) => { checkPlugin(plugin.manifest.id); }); + } else { + checkPlugin(pluginOrTeam); } }; diff --git a/packages/kbn-plugin-check/index.ts b/packages/kbn-plugin-check/index.ts index 6ccb55ccca36b..ffb38708bc5c0 100644 --- a/packages/kbn-plugin-check/index.ts +++ b/packages/kbn-plugin-check/index.ts @@ -26,12 +26,6 @@ export const runPluginCheckCli = () => { } if (flags.dependencies) { - if ((!flags.plugin && !flags.team) || (flags.plugin && flags.team)) { - throw new Error( - 'Either --plugin or --team must or may be specified when checking dependencies.' - ); - } - checkDependencies(flags, log); } @@ -48,14 +42,13 @@ export const runPluginCheckCli = () => { defaultLevel: 'info', }, flags: { - boolean: ['dependencies', 'rank'], - string: ['plugin', 'team', 'dependents'], + boolean: ['rank'], + string: ['dependencies', 'dependents'], help: ` - --rank Display plugins as a ranked list of usage. - --dependents [plugin] Display plugins that depend on a given plugin. - --dependencies Check plugin dependencies. - --plugin [plugin] The plugin to check. - --team [team] Check all plugins owned by a given team. + --rank Display plugins as a ranked list of usage. + --dependents [plugin] Display plugins that depend on a given plugin. + --dependencies [plugin] Check plugin dependencies for a single plugin. + --dependencies [team] Check dependencies for all plugins owned by a team. `, }, }