diff --git a/bin/console b/bin/console index f3bd538..13fcbae 100755 --- a/bin/console +++ b/bin/console @@ -31,6 +31,6 @@ $command[] = new DevCoding\Jss\Easy\Command\Preferences\CC\BackupCommand(); $command[] = new DevCoding\Jss\Easy\Command\Preferences\CC\TransferCommand(); // Other Commands $command[] = new DevCoding\Jss\Easy\Command\PrepCommand(); -$app = new Application('Jez', 'v4.0.9'); +$app = new Application('Jez', 'v4.0.10'); $app->addCommands($command); $app->run(); diff --git a/composer.json b/composer.json index 5ef8a73..8acf5cf 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "prefer-stable": true, "minimum-stability": "dev", - "version": "4.0.9", + "version": "4.0.10", "require": { "php": ">=7.1", "ext-json": "*", diff --git a/dist/jez.phar b/dist/jez.phar index b1329c7..a1eb8f2 100755 Binary files a/dist/jez.phar and b/dist/jez.phar differ diff --git a/src/Command/Download/AbstractInstallConsole.php b/src/Command/Download/AbstractInstallConsole.php index fe1c555..b96bce3 100644 --- a/src/Command/Download/AbstractInstallConsole.php +++ b/src/Command/Download/AbstractInstallConsole.php @@ -364,6 +364,11 @@ protected function isVersionMatch($app_or_ver) $new = $this->getAppVersion($this->getDestination()); $comp = ($app_or_ver instanceof MacApplication) ? $this->getAppVersion($app_or_ver) : $app_or_ver; + if (0 == strpos($new->getRaw(), 'Build _')) + { + $new = new SemanticVersion('0.0+'.$new->getBuild()); + } + return $new instanceof SemanticVersion && $comp instanceof SemanticVersion && $new->eq($comp); } diff --git a/src/Object/Recipe/GenericRecipe.php b/src/Object/Recipe/GenericRecipe.php index 328f862..0a6979e 100644 --- a/src/Object/Recipe/GenericRecipe.php +++ b/src/Object/Recipe/GenericRecipe.php @@ -96,9 +96,14 @@ public function isMatch(MacApplication $offered) } else { - $cVer = new SemanticVersion($this->getCurrentVersion()); + $cVer = new SemanticVersion($ver); $oVer = $offered->getShortVersion() ?? $offered->getVersion(); + if (0 == strpos($oVer->getRaw(), 'Build _')) + { + $oVer = new SemanticVersion('0.0+'.$oVer->getBuild()); + } + if ($oVer->eq($cVer)) { return true; diff --git a/src/Object/Recipe/SublimeText.php b/src/Object/Recipe/SublimeText.php new file mode 100644 index 0000000..b3ac64c --- /dev/null +++ b/src/Object/Recipe/SublimeText.php @@ -0,0 +1,89 @@ + + * @license https://github.com/deviscoding/jss-helper/blob/main/LICENSE + */ +class SublimeText extends AbstractRecipe +{ + protected $version; + + public function getName() + { + return 'Sublime Text'; + } + + public function getPath() + { + return '/Applications/Sublime Text.app'; + } + + public function getDownloadUrl() + { + $build = str_replace('0.0+', '', $this->getCurrentVersion()); + + return sprintf('https://download.sublimetext.com/sublime_text_build_%s_mac.zip', $build); + } + + public function getDestinationUrl() + { + return $this->getDownloadUrl(); + } + + public function getInstallerType() + { + return $this->getInstallerTypeFromUrl($this->getDownloadUrl()); + } + + public function getCurrentVersion() + { + if (!isset($this->version)) + { + if ($notes = $this->getReleaseNotes()) + { + $crawler = new Crawler($notes); + $crawler = $crawler->filter('#changelog'); + if ($crawler->count() > 0) + { + $crawler = $crawler->filter('article')->reduce(function (Crawler $node, $i) { + $href = $node->attr('class'); + + return false !== stripos($href, 'current'); + }); + + if ($h3 = $crawler->filter('h3')) + { + $this->version = '0.0+'.str_replace('Build ', '', $h3->html()); + } + } + } + } + + return $this->version; + } + + /** + * Grabs the HTML of the updates page. + * + * @return string|null + */ + protected function getReleaseNotes() + { + $url = 'https://www.sublimetext.com/download'; + $ua = $this->getUserAgent(); + + if ($resp = (new DownloadHelper())->getUrl($url, null, null, $ua)) + { + return $resp['body'] ?? null; + } + + return null; + } +}