Add support for Packagist (Composer)
This commit is contained in:
parent
ac7ed64118
commit
f02e6e2c31
|
@ -31,6 +31,7 @@ Contents
|
|||
* `Check NPM Registry <#check-npm-registry>`_
|
||||
* `Check Hackage <#check-hackage>`_
|
||||
* `Check CPAN <#check-cpan>`_
|
||||
* `Check Packagist <#check-packagist>`_
|
||||
* `Check Local Pacman Database <#check-local-pacman-database>`_
|
||||
* `Check Arch Linux official packages <#check-arch-linux-official-packages>`_
|
||||
* `Check Google Code (hg repository) <#check-google-code-hg-repository>`_
|
||||
|
@ -258,6 +259,13 @@ Check `MetaCPAN <https://metacpan.org/>`_ for updates.
|
|||
cpan
|
||||
The name used on CPAN, e.g. ``YAML``.
|
||||
|
||||
Check Packagist
|
||||
--------------
|
||||
Check `Packagist <https://packagist.org/>`_ for updates.
|
||||
|
||||
packagist
|
||||
The name used on Packagist, e.g. ``monolog/monolog``.
|
||||
|
||||
Check Local Pacman Database
|
||||
---------------------------
|
||||
This is used when you run ``nvchecker`` on an Arch Linux system and the program always keeps up with a package in your configured repositories for `Pacman`_.
|
||||
|
|
|
@ -5,7 +5,7 @@ logger = logging.getLogger(__name__)
|
|||
handler_precedence = (
|
||||
'github', 'gitcafe', 'aur', 'pypi', 'archpkg', 'gems', 'pacman',
|
||||
'cmd', 'bitbucket', 'gcode_hg', 'gcode_svn', 'regex', 'manual', 'vcs',
|
||||
'npm', 'hackage', 'cpan', 'gitlab',
|
||||
'npm', 'hackage', 'cpan', 'gitlab', 'packagist'
|
||||
)
|
||||
|
||||
def get_version(name, conf, callback):
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
from .simple_json import simple_json
|
||||
|
||||
PACKAGIST_URL = 'https://packagist.org/packages/%s.json'
|
||||
|
||||
def _version_from_json(data):
|
||||
data = {version: details for version, details in data["package"]['versions'].items() if version != "dev-master"}
|
||||
|
||||
if len(data):
|
||||
return max(data, key=lambda version: data[version]["time"])
|
||||
|
||||
get_version = simple_json(
|
||||
PACKAGIST_URL,
|
||||
'packagist',
|
||||
_version_from_json,
|
||||
)
|
|
@ -0,0 +1,6 @@
|
|||
from tests.helper import ExternalVersionTestCase
|
||||
|
||||
|
||||
class PackagistTest(ExternalVersionTestCase):
|
||||
def test_packagist(self):
|
||||
self.assertEqual(self.sync_get_version("butterfly/example-web-application", {"packagist": None}), "1.2.0")
|
Loading…
Reference in New Issue