Report only upgraded packages

This commit is contained in:
Daniil Gentili 2020-01-18 19:05:43 +01:00
parent f01871a0e8
commit 0003ada3ff
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7

View File

@ -82,18 +82,35 @@ function ___install_madeline()
$phar = \file_get_contents(\sprintf($phar_template, $release_branch)); $phar = \file_get_contents(\sprintf($phar_template, $release_branch));
if ($phar) { if ($phar) {
$extractVersions = static function () {
if (!file_exists('phar://madeline.phar/vendor/composer/installed.json')) {
return array();
}
$composer = \json_decode(\file_get_contents('phar://madeline.phar/vendor/composer/installed.json'), true);
$packages = array();
foreach ($composer as $dep) {
$packages[$dep['name']] = $dep['version_normalized'];
}
return $packages;
};
$previous = $extractVersions();
$previous['danog/madelineproto'] = 'old';
\file_put_contents('madeline.phar', $phar); \file_put_contents('madeline.phar', $phar);
\file_put_contents('madeline.phar.version', $release); \file_put_contents('madeline.phar.version', $release);
$current = $extractVersions();
$composer = \json_decode(\file_get_contents('phar://madeline.phar/vendor/composer/installed.json'), true); $postData = array('downloads' => array());
$postData = ['downloads' => []]; foreach ($current as $name => $version) {
foreach ($composer as $dep) { if (isset($previous[$name]) && $previous[$name] === $version) {
continue;
}
$postData['downloads'][] = [ $postData['downloads'][] = [
'name' => $dep['name'], 'name' => $name,
'version' => $dep['version_normalized'] 'version' => $version
]; ];
} }
$opts = ['http' => $opts = ['http' =>
[ [
'method' => 'POST', 'method' => 'POST',