2020-08-17 14:04:44 +00:00
|
|
|
# MIT licensed
|
|
|
|
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
|
|
|
|
|
2023-10-18 00:00:46 +00:00
|
|
|
from nvchecker.api import RichResult
|
|
|
|
|
2020-08-17 14:04:44 +00:00
|
|
|
PACKAGIST_URL = 'https://packagist.org/packages/%s.json'
|
|
|
|
|
|
|
|
async def get_version(name, conf, *, cache, **kwargs):
|
|
|
|
key = conf.get('packagist', name)
|
|
|
|
data = await cache.get_json(PACKAGIST_URL % key)
|
|
|
|
|
|
|
|
versions = {
|
|
|
|
version: details
|
|
|
|
for version, details in data["package"]['versions'].items()
|
|
|
|
if version != "dev-master"
|
|
|
|
}
|
|
|
|
|
2020-08-18 08:45:20 +00:00
|
|
|
if len(versions):
|
2023-10-18 00:00:46 +00:00
|
|
|
version = max(versions, key=lambda version: versions[version]["time"])
|
|
|
|
return RichResult(
|
|
|
|
version = version,
|
|
|
|
url = f'https://packagist.org/packages/{data["package"]["name"]}#{version}',
|
|
|
|
)
|