Rework support for @latest version #752
Merged
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.
Currently, unpkg and jsdelivr support using 'latest' as a version. When files are requested by libman, they redirect (HTTP302) to the URL for the current latest files. We put those files into the cache like any other version (in a folder name 'latest') and all is well.
However, when a new version is released, libman continues to use the now-stale downloaded assets from the cache. There isn't a signal to realize when to purge the latest version from the cache.
This change instead simply turns 'latest' into the latest version we determine from the provider. There is a small risk that we are out of sync with the CDN: for example, since we get the version data from NPM, it might not match the version that e.g. jsdelivr redirects to. But this should be extremely rare.
Doing it this way also allows cdnjs to support 'latest'. I didn't add it to the completion items, but I did verify that it works (CLI install, restore, and the file list in VS all support foo@latest for cdnjs now too).
Resolves #748