shields icon indicating copy to clipboard operation
shields copied to clipboard

Add support of Visual Studio Code prerelease extensions to the version badge

Open lextm opened this issue 2 years ago • 3 comments

:clipboard: Description

Visual Studio Code started to support prerelease versions of extensions for a while, but the version badge (/visual-studio-marketplace/v/:extensionId) does not support switching between the stable/prerelease channels,

https://code.visualstudio.com/updates/v1_63#_pre-release-extensions

For end users, they might wonder why a version (prerelease) showed in this badge is not available to install on their machines.

lextm avatar Jul 20 '22 04:07 lextm

Most of our version badges have 2 variants:

  • /v/packageName
  • /v/packageName?include_prereleases

It would be nice if we could do the same here. Looking at the API response we get back from the VS Marketplace API I'm not sure if we get a pre-release flag. Do you have an example of an extension with a mix of pre and stable releases?

chris48s avatar Jul 21 '22 20:07 chris48s

You might use my extension as example,

https://marketplace.visualstudio.com/items?itemName=lextudio.restructuredtext

All old versions (189.x.x and below) are stable releases, while new versions (190.x.x) are all pre releases. Thus,

  • A stable version badge should show 189.1.0.
  • A prerelease version badge should show 190.1.4.

lextm avatar Jul 22 '22 00:07 lextm

OK. Thanks for the example. It looks like if we call

curl -X POST "https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery/" --data "{\"filters\":[{\"criteria\":[{\"filterType\":7,\"value\":\"lextudio.restructuredtext\"}]}],\"flags\":0x10}" --header "Accept: application/json;api-version=3.0-preview.1" --header "Content-Type: application/json"

(note "flags":0x10 in the POST body)

there is a

{
  "key": "Microsoft.VisualStudio.Code.PreRelease",
  "value": "true"
}

value we can look for in the version properties array to identify pre-releases

chris48s avatar Jul 23 '22 14:07 chris48s

@chris48s Hi, I'm a first time contributor and would like to try and work on this issue :) I've read the relevant docs, cloned the repo and started digging in the code.

I'd appreciate some general guidance in terms of the files to look at. From what I've read so far, it seems the relevant place would be the base class at visual-studio-marketplace-base.js, the service at visual-studio-marketplace-version.service.js and the tester.

Am I correct? Anything else that's important?

Please let me know if this could be assigned to me. Thanks.

OronW avatar Oct 15 '22 21:10 OronW

From what I've read so far, it seems the relevant place would be the base class at visual-studio-marketplace-base.js, the service at visual-studio-marketplace-version.service.js and the tester.

Bingo. Also if you grep for include_prereleases you can find how that param is implemented for other services. Docs are in https://github.com/badges/shields/tree/master/doc Cheers

chris48s avatar Oct 17 '22 16:10 chris48s

@chris48s Hey, I've created a PR with my changes, at: https://github.com/badges/shields/pull/8561

Seems that the tests have passed and now I'll wait for a review. Is there anything else needed from my side at the mean time?

Thanks.

OronW avatar Oct 22 '22 21:10 OronW