Make template upgrade kinder to old installs of common repos #1152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If a user has template installs from 0.8 or earlier, they will not have repo information. So if the user tries to upgrade them, they will instead get prompted to install-update them.
This PR attempts to provide a better experience for the Spin and Spin JS SDK repos, which are the ones users are most likely to have existing installs of. It tries, heuristically, to detect if the user has old installs of those repos, and if so inserts them into the list of repos to offer for upgrade. This means that a user who has installed from one of those repos in the past will now get the nice auto upgrade rather than being asked to use the incantation. E.g.:
There are a couple of ways this can go wrong:
The heuristic is fooled if the user has uninstalled the templates we use for sniffing. In this case the user will be shown the remaining templates as "we couldn't tell where to upgrade from." This is not delightful but it is benign and a user who is engaged enough to curate individual templates can probably deal with it.
If the user is sniffed as having the special repos, we hide all manual upgrade warnings. This is to avoid embedding a full list of special templates into the code. If the user has other templates that cannot be upgraded, from other repos or from local directories, no warning will be displayed for these. Once the user has upgraded their blessed repos, so that they have origin info, the warnings for the skipped templates will reappear. This behaviour is admittedly weird and hard to explain to users, but I think the number of people affected will be very small.
Otherwise it seems to work correctly though I'm a bit anxious about having logic this complicated. Hopefully we can remove it after a few releases!