The install plugins shell script will ALWAYS download a plugin that is requested. It will only download a dependency plugin, one needed by a requested plugin recursively, if that plugin is not already installed in a version equal or greater than the one required.
The current plugin installation manager cli tool treats requested and dependency plugins identically in this regard. Neither requested nor dependency plugins are downloaded if the plugin is already installed and the required version is less than the installed version for that plugin.
Change to download a requested plugin even if it is already installed and use the version calculated already using requested and dependency versions.
Note that the script will download a plugin more than once since it does version comparisons (for dependency plugins) as it finds the dependencies. The cli tool adds the plugin to the "download list" as it find the dependencies and downloads only once for each plugin.
I don't think we should change the cli tool to download multiple times for a single plugin but here are the cases in which the install plugins script it will do that. I may not have thought of all the possible cases:
1) If a plugin is requested more than once, it will be downloaded multiple times. Only the last version downloaded (last version in the requested plugin list) will remain. Note that requesting plugins in txt files, yaml files and via command line option does not make it clear what order plugins are requested in.
2) If a plugin is requested it is always downloaded. If it is also a dependency of another requested plugin, it might be downloaded. The script chooses to download by comparing requested version to the installed version. I think, it uses the version installed at the start of the update cli tool run. Although the install plugins shell script seems to have a bug that makes it always choose LATEST for dependency plugins, this could mean multiple versions get installed. The last one installed will remain.
3) Multiple requested plugins could have the same plugin as a dependency. Perhaps with the same version. Perhaps with different versions. The result is similar to the case in 2) above.
Based on this, I think the requirement for the plugin installation manager cli tool should be:
- Always download a requested plugin.
- For requested plugins, if two versions are requested, more discussion is needed. The options are a) fail or b) use the greater of the two versions.
- For dependency plugins, choose the version using the minimum required version as listed in the plugin that shows it as a dependency.
- For dependency plugins, if two or more versions are found to be needed, use the greatest of the versions.
- If a requested plugin is also a dependency plugin and the versions are different, I think it should use the greatest of the versions. Note: Perhaps this situation should fail as well suggesting the user request the greatest of the dependency versions.