diff --git a/docs/usage.rst b/docs/usage.rst index 7b1f362..3ac4e4b 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -825,6 +825,17 @@ strip_release provided Instead of the package version, return the version this package provides. Its value is what the package provides, and ``strip_release`` takes effect too. This is best used with libraries. +Check Open Vsx +~~~~~~~~~~~~~~~ +:: + + source = "openvsx" + +Check `Open Vsx `_ for updates. + +openvsx + The extension's Unique Identifier on open-vsx.org, e.g. ``ritwickdey.LiveServer``. + Combine others' results ~~~~~~~~~~~~~~~~~~~~~~~ :: diff --git a/nvchecker_source/openvsx.py b/nvchecker_source/openvsx.py new file mode 100644 index 0000000..7b65119 --- /dev/null +++ b/nvchecker_source/openvsx.py @@ -0,0 +1,13 @@ +# MIT licensed +# Copyright (c) 2013-2021 Th3Whit3Wolf , et al. + +API_URL = 'https://open-vsx.org/api/%s/%s' + +async def get_version(name, conf, *, cache, **kwargs): + name = conf.get('openvsx') or name + splitName = name.split('.') + publisher = splitName[0] + extension = splitName[1] + data = await cache.get_json(API_URL % (publisher, extension)) + version = data['version'] + return version diff --git a/tests/test_openvsx.py b/tests/test_openvsx.py new file mode 100644 index 0000000..faac45f --- /dev/null +++ b/tests/test_openvsx.py @@ -0,0 +1,10 @@ +# MIT licensed +# Copyright (c) 2013-2021 Th3Whit3Wolf , et al. + +import pytest +pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] + +async def test_openvsx(get_version): + assert await get_version("usernamehw.indent-one-space", { + "source": "openvsx", + }) == "0.2.6" \ No newline at end of file