(loadedPlugin, config, commandPrefix = '')
| 32 | * @param {string} commandPrefix - The prefix for the command (default is ''). |
| 33 | */ |
| 34 | const resolveCommands = (loadedPlugin, config, commandPrefix = '') => { |
| 35 | if (!config.commands) return |
| 36 | for (const [commandName, commandConfig] of Object.entries( |
| 37 | config.commands, |
| 38 | )) { |
| 39 | if (commandConfig.type === 'entrypoint') continue |
| 40 | const fullCommandName = `${commandPrefix}${commandName}` |
| 41 | if (commandConfig.type !== 'container') { |
| 42 | const schema = commands.has(fullCommandName) |
| 43 | ? _.merge({}, commands.get(fullCommandName)) |
| 44 | : { |
| 45 | usage: commandConfig.usage, |
| 46 | serviceDependencyMode: 'required', |
| 47 | isExtension: true, |
| 48 | sourcePlugin: loadedPlugin, |
| 49 | isHidden: commandConfig.isHidden, |
| 50 | noSupportNotice: commandConfig.noSupportNotice, |
| 51 | options: {}, |
| 52 | } |
| 53 | if (commandConfig.lifecycleEvents) |
| 54 | schema.lifecycleEvents = commandConfig.lifecycleEvents |
| 55 | if (commandConfig.options) { |
| 56 | for (const [optionName, optionConfig] of Object.entries( |
| 57 | commandConfig.options, |
| 58 | )) { |
| 59 | if (!schema.options[optionName]) { |
| 60 | schema.options[optionName] = optionConfig |
| 61 | if (!optionConfig.type) { |
| 62 | if (!missingOptionTypes.has(loadedPlugin)) { |
| 63 | missingOptionTypes.set(loadedPlugin, new Set()) |
| 64 | } |
| 65 | missingOptionTypes.get(loadedPlugin).add(optionName) |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // Put common options to end of index |
| 72 | for (const optionName of Object.keys(commonOptions)) |
| 73 | delete schema.options[optionName] |
| 74 | Object.assign(schema.options, commonOptions) |
| 75 | |
| 76 | commands.set(fullCommandName, schema) |
| 77 | } |
| 78 | resolveCommands(loadedPlugin, commandConfig, `${fullCommandName} `) |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | for (const loadedPlugin of loadedPlugins) |
| 83 | resolveCommands(loadedPlugin, loadedPlugin) |
no test coverage detected
searching dependent graphs…