Skip to content

Commit

Permalink
fix updater
Browse files Browse the repository at this point in the history
Took 23 minutes
  • Loading branch information
fabio-ivona committed Sep 7, 2021
1 parent cb0dba7 commit d1ba1d7
Show file tree
Hide file tree
Showing 2 changed files with 691 additions and 288 deletions.
15 changes: 4 additions & 11 deletions app/Updater/GithubStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class GithubStrategy implements StrategyInterface
{
const API_URL = 'https://packagist.org/packages/%s.json';
const API_URL = 'https://repo.packagist.org/p2/%s.json';

const STABLE = 'stable';

Expand Down Expand Up @@ -86,6 +86,7 @@ public function getCurrentRemoteVersion(Updater $updater)
/** Switch remote request errors to HttpRequestExceptions */
set_error_handler(array($updater, 'throwHttpRequestException'));
$packageUrl = $this->getApiUrl();

$package = json_decode(humbug_get_contents($packageUrl), true);
restore_error_handler();

Expand All @@ -96,15 +97,7 @@ public function getCurrentRemoteVersion(Updater $updater)
);
}

$versions = array_keys($package['package']['versions']);
$versionParser = new VersionParser($versions);
if ($this->getStability() === self::STABLE) {
$this->remoteVersion = $versionParser->getMostRecentStable();
} elseif ($this->getStability() === self::UNSTABLE) {
$this->remoteVersion = $versionParser->getMostRecentUnstable();
} else {
$this->remoteVersion = $versionParser->getMostRecentAll();
}
$this->remoteVersion = $package['packages'][$this->getPackageName()][0]['version'];

echo 'remote version: ' . $this->remoteVersion . PHP_EOL. PHP_EOL;

Expand Down Expand Up @@ -214,7 +207,7 @@ protected function getDownloadUrl(array $package)
$baseUrl = preg_replace(
'{\.git$}',
'',
$package['package']['versions'][$this->remoteVersion]['source']['url']
$package['packages'][$this->getPackageName()][0]['source']['url']
);
$downloadUrl = sprintf(
'%s/releases/download/%s/%s',
Expand Down
Loading

0 comments on commit d1ba1d7

Please sign in to comment.