nix-community / nix-vscode-extensions

Nix expressions for VSCode and OpenVSX extensions [maintainers: @deemp, @AmeerTaweel]
MIT License
234 stars 13 forks source link

Filter out pre-release versions #18

Closed anilanar closed 1 year ago

anilanar commented 1 year ago

Biggest pain for us right now is the gitlens extension, which we have to update every other day because nix-vscode-extensions points to a pre-release version and new pre-release versions require updating the extension otherwise the extension gets deactivated.

I wonder if the API that is crawled has more information about stable vs. pre-release versions.

anilanar commented 1 year ago

Versions have the following property in properties array, but versions array contains only the latest version.

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

Maybe there's a way to apply a filter in the POST request.

anilanar commented 1 year ago

I confirm that stable versions don't contain PreRelease key in properties. Example from gitlens:

   {
                            "version": "13.5.0",
                            "flags": "validated",
                            "lastUpdated": "2023-04-07T17:41:21.193Z",
                            "files": [
                                {
                                    "assetType": "Microsoft.VisualStudio.Code.Manifest",
                                    "source": "https://eamodio.gallerycdn.vsassets.io/extensions/eamodio/gitlens/13.5.0/1680889071612/Microsoft.VisualStudio.Code.Manifest"
                                },
                                {
                                    "assetType": "Microsoft.VisualStudio.Services.Content.Changelog",
                                    "source": "https://eamodio.gallerycdn.vsassets.io/extensions/eamodio/gitlens/13.5.0/1680889071612/Microsoft.VisualStudio.Services.Content.Changelog"
                                },
                                {
                                    "assetType": "Microsoft.VisualStudio.Services.Content.Details",
                                    "source": "https://eamodio.gallerycdn.vsassets.io/extensions/eamodio/gitlens/13.5.0/1680889071612/Microsoft.VisualStudio.Services.Content.Details"
                                },
                                {
                                    "assetType": "Microsoft.VisualStudio.Services.Content.License",
                                    "source": "https://eamodio.gallerycdn.vsassets.io/extensions/eamodio/gitlens/13.5.0/1680889071612/Microsoft.VisualStudio.Services.Content.License"
                                },
                                {
                                    "assetType": "Microsoft.VisualStudio.Services.Icons.Default",
                                    "source": "https://eamodio.gallerycdn.vsassets.io/extensions/eamodio/gitlens/13.5.0/1680889071612/Microsoft.VisualStudio.Services.Icons.Default"
                                },
                                {
                                    "assetType": "Microsoft.VisualStudio.Services.Icons.Small",
                                    "source": "https://eamodio.gallerycdn.vsassets.io/extensions/eamodio/gitlens/13.5.0/1680889071612/Microsoft.VisualStudio.Services.Icons.Small"
                                },
                                {
                                    "assetType": "Microsoft.VisualStudio.Services.VsixManifest",
                                    "source": "https://eamodio.gallerycdn.vsassets.io/extensions/eamodio/gitlens/13.5.0/1680889071612/Microsoft.VisualStudio.Services.VsixManifest"
                                },
                                {
                                    "assetType": "Microsoft.VisualStudio.Services.VSIXPackage",
                                    "source": "https://eamodio.gallerycdn.vsassets.io/extensions/eamodio/gitlens/13.5.0/1680889071612/Microsoft.VisualStudio.Services.VSIXPackage"
                                },
                                {
                                    "assetType": "Microsoft.VisualStudio.Services.VsixSignature",
                                    "source": "https://eamodio.gallerycdn.vsassets.io/extensions/eamodio/gitlens/13.5.0/1680889071612/Microsoft.VisualStudio.Services.VsixSignature"
                                }
                            ],
                            "properties": [
                                {
                                    "key": "Microsoft.VisualStudio.Services.Branding.Color",
                                    "value": "#8647ae"
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Services.Branding.Theme",
                                    "value": "dark"
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Services.Links.Getstarted",
                                    "value": "https://github.com/gitkraken/vscode-gitlens.git"
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Services.Links.Support",
                                    "value": "https://github.com/gitkraken/vscode-gitlens/issues"
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Services.Links.Learn",
                                    "value": "https://gitkraken.com/gitlens"
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Services.Links.Source",
                                    "value": "https://github.com/gitkraken/vscode-gitlens.git"
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Services.Links.GitHub",
                                    "value": "https://github.com/gitkraken/vscode-gitlens.git"
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Code.Engine",
                                    "value": "^1.72.0"
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown",
                                    "value": "true"
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Code.ExtensionDependencies",
                                    "value": ""
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Code.ExtensionPack",
                                    "value": ""
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Code.LocalizedLanguages",
                                    "value": ""
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Code.ExtensionKind",
                                    "value": "workspace,web"
                                },
                                {
                                    "key": "Microsoft.VisualStudio.Services.Content.Pricing",
                                    "value": "Free"
                                }
                            ],
                            "assetUri": "https://eamodio.gallerycdn.vsassets.io/extensions/eamodio/gitlens/13.5.0/1680889071612",
                            "fallbackAssetUri": "https://eamodio.gallery.vsassets.io/_apis/public/gallery/publisher/eamodio/extension/gitlens/13.5.0/assetbyname"
                        },

Latest version that doesn't contain { "key": "Microsoft.VisualStudio.Code.PreRelease", "value": "true" }, if cannot be found, then the latest version would do it.

What do you think?

AmeerTaweel commented 1 year ago

What you said makes sense. I don't have much time to work on this repo now because we're approaching the end of the semester in my university. I can work on it in the summer if no one else does.

twz123 commented 1 year ago

Side note to this: The Marketplace API also reports the minimum required VSCode version (somewhere :angel:, maybe in "Microsoft.VisualStudio.Code.Engine"?). It happened to me quite a few times that I updated to the latest extension versions, just to realize that they're not compatible to the (too old) VSCode version I was using. Would be awesome if it'd be possible to select the latest extension version based on the VSCode version in use.

deemp commented 1 year ago

@twz123 , I'll add the information about the required minimal engine version into cache. Then, it'll be possible to filter out the extensions that require a version of VSCode that's greater than a specified one.

deemp commented 1 year ago

This query gave me all versions of gitlens. I got this query after playing with flags. However, I could not make the API return the latest non-PreRelease version.

cat <<'EOF' | curl -sSL -H 'Accept: application/json;api-version=6.1-preview.1' -H 'Content-Type: application/json' https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery? -d @- > eamodio-gitlens.json
{
    "assetTypes": [],
    "filters": [
        {
            "criteria": [
                {
                    "filterType": 8,
                    "value": "Microsoft.VisualStudio.Code"
                },
                {
                    "filterType": 7,
                    "value": "eamodio.gitlens"
                }
            ],
            "pageNumber": 1,
            "pageSize": 2
        }
    ],
    "flags": 1073
}
EOF