示例#1
0
 public function index()
 {
     $page_title = 'BFAdminCP Updater';
     $latest_release = Cache::remember('latest_release', 30, function () {
         $response = $this->guzzle->get('https://api.github.com/repos/Prophet731/BFAdminCP/releases/latest');
         $latest_release = $response->json();
         return $latest_release;
     });
     $releases = Cache::remember('releases', 30, function () {
         $response = $this->guzzle->get('https://api.github.com/repos/Prophet731/BFAdminCP/releases');
         $releases = $response->json();
         return $releases;
     });
     $outofdate = version::lt(BFACP_VERSION, $latest_release['tag_name']);
     $unreleased = version::gt(BFACP_VERSION, $latest_release['tag_name']);
     return View::make('system.updater.index', compact('page_title', 'releases', 'outofdate', 'latest_release', 'unreleased'));
 }
示例#2
0
 function testEquality()
 {
     $compare = array(array("1.2.3", "v1.2.3"), array("1.2.3", "=1.2.3"), array("1.2.3", "v 1.2.3"), array("1.2.3", "= 1.2.3"), array("1.2.3", " v1.2.3"), array("1.2.3", " =1.2.3"), array("1.2.3", " v 1.2.3"), array("1.2.3", " = 1.2.3"), array("1.2.3-0", "v1.2.3-0"), array("1.2.3-0", "=1.2.3-0"), array("1.2.3-0", "v 1.2.3-0"), array("1.2.3-0", "= 1.2.3-0"), array("1.2.3-0", " v1.2.3-0"), array("1.2.3-0", " =1.2.3-0"), array("1.2.3-0", " v 1.2.3-0"), array("1.2.3-0", " = 1.2.3-0"), array("1.2.3-01", "v1.2.3-1"), array("1.2.3-01", "=1.2.3-1"), array("1.2.3-01", "v 1.2.3-1"), array("1.2.3-01", "= 1.2.3-1"), array("1.2.3-01", " v1.2.3-1"), array("1.2.3-01", " =1.2.3-1"), array("1.2.3-01", " v 1.2.3-1"), array("1.2.3-01", " = 1.2.3-1"), array("1.2.3beta", "v1.2.3beta"), array("1.2.3beta", "=1.2.3beta"), array("1.2.3beta", "v 1.2.3beta"), array("1.2.3beta", "= 1.2.3beta"), array("1.2.3beta", " v1.2.3beta"), array("1.2.3beta", " =1.2.3beta"), array("1.2.3beta", " v 1.2.3beta"), array("1.2.3beta", " = 1.2.3beta"));
     foreach ($compare as $set) {
         $a = $set[0];
         $b = $set[1];
         $this->assertTrue(SemVer\version::eq($a, $b), "%s > eq('" . $a . "', '" . $b . "')");
         $this->assertFalse(SemVer\version::neq($a, $b), "%s > !neq('" . $a . "', '" . $b . "')");
         $this->assertTrue(SemVer\version::cmp($a, "==", $b), "%s > cmp(" . $a . "==" . $b . ")");
         $this->assertFalse(SemVer\version::cmp($a, "!=", $b), "%s > !cmp(" . $a . "!=" . $b . ")");
         $this->assertFalse(SemVer\version::cmp($a, "===", $b), "%s > !cmp(" . $a . "===" . $b . ")");
         $this->assertTrue(SemVer\version::cmp($a, "!==", $b), "%s > cmp(" . $a . "!==" . $b . ")");
         $this->assertFalse(SemVer\version::gt($a, $b), "%s > !gt('" . $a . "', '" . $b . "')");
         $this->assertTrue(SemVer\version::gte($a, $b), "%s > gte('" . $a . "', '" . $b . "')");
         $this->assertFalse(SemVer\version::lt($a, $b), "%s > !lt('" . $a . "', '" . $b . "')");
         $this->assertTrue(SemVer\version::lte($a, $b), "%s > lte('" . $a . "', '" . $b . "')");
     }
 }
 /**
  * Check if a new version is available.
  *
  * @return bool
  */
 public function newVersionAvailable()
 {
     return version::gt($this->_latestVersion, $this->_currentVersion);
 }
示例#4
0
 function testBug24()
 {
     $this->assertFalse(SemVer\version::gt('4.0.0-beta.9', '4.0.0-beta.10'), '4.0.0-beta.9 < 4.0.0-beta.10 (Bug #24)');
 }
示例#5
0
文件: Project.php 项目: jpalala/codex
 /**
  * Get refs sorted by the configured order.
  *
  * @return array
  */
 public function getSortedRefs()
 {
     $versions = $this->versions;
     usort($versions, function (version $v1, version $v2) {
         return version::gt($v1, $v2) ? -1 : 1;
     });
     $versions = array_map(function (version $v) {
         return $v->getVersion();
     }, $versions);
     return array_merge($this->branches, $versions);
 }
示例#6
0
 protected function apply_patches($from, $to, $post_process, Setup_Upgrade $upgrader, Application $app)
 {
     if (version::eq($from, $to)) {
         return true;
     }
     $list_patches = [];
     $upgrader->add_steps(1)->set_current_message($app->trans('Looking for patches'));
     $iterator = new DirectoryIterator($this->app['root.path'] . '/lib/classes/patch/');
     foreach ($iterator as $fileinfo) {
         if (!$fileinfo->isDot()) {
             if (substr($fileinfo->getFilename(), 0, 1) == '.') {
                 continue;
             }
             $versions = array_reverse(explode('.', $fileinfo->getFilename()));
             $classname = 'patch_' . array_pop($versions);
             $patch = new $classname();
             if (!in_array($this->get_base_type(), $patch->concern())) {
                 continue;
             }
             if (!!$post_process !== !!$patch->require_all_upgrades()) {
                 continue;
             }
             // if patch is older than current install
             if (version::lte($patch->get_release(), $from)) {
                 continue;
             }
             // if patch is new than current target
             if (version::gt($patch->get_release(), $to)) {
                 continue;
             }
             $n = 0;
             do {
                 $key = $patch->get_release() . '.' . $n;
                 $n++;
             } while (isset($list_patches[$key]));
             $list_patches[$key] = $patch;
         }
     }
     $upgrader->add_steps_complete(1)->add_steps(count($list_patches))->set_current_message($app->trans('Applying patches on %databox_name%', ['%databox_name%' => $this->get_dbname()]));
     uasort($list_patches, function (\patchInterface $patch1, \patchInterface $patch2) {
         return version::lt($patch1->get_release(), $patch2->get_release()) ? -1 : 1;
     });
     $success = true;
     foreach ($list_patches as $patch) {
         // Gets doctrine migrations required for current patch
         foreach ($patch->getDoctrineMigrations() as $doctrineVersion) {
             $version = $app['doctrine-migration.configuration']->getVersion($doctrineVersion);
             // Skip if already migrated
             if ($version->isMigrated()) {
                 continue;
             }
             $migration = $version->getMigration();
             // Inject entity manager
             $migration->setEntityManager($app['EM']);
             // Execute migration if not marked as migrated and not already applied by an older patch
             if (!$migration->isAlreadyApplied()) {
                 $version->execute('up');
                 continue;
             }
             // Or mark it as migrated
             $version->markMigrated();
         }
         if (false === $patch->apply($this, $app)) {
             $success = false;
         }
         $upgrader->add_steps_complete(1);
     }
     return $success;
 }
 public function applyPatches(\base $base, $from, $to, $post_process)
 {
     if (version::eq($from, $to)) {
         return true;
     }
     $list_patches = [];
     $iterator = new \DirectoryIterator($this->app['root.path'] . '/lib/classes/patch/');
     foreach ($iterator as $fileinfo) {
         if (!$fileinfo->isDot()) {
             if (substr($fileinfo->getFilename(), 0, 1) == '.') {
                 continue;
             }
             $versions = array_reverse(explode('.', $fileinfo->getFilename()));
             $classname = 'patch_' . array_pop($versions);
             /** @var \patchAbstract $patch */
             $patch = new $classname();
             if (!in_array($base->get_base_type(), $patch->concern())) {
                 continue;
             }
             if (!!$post_process !== !!$patch->require_all_upgrades()) {
                 continue;
             }
             // if patch is older than current install
             if (version::lte($patch->get_release(), $from)) {
                 continue;
             }
             // if patch is new than current target
             if (version::gt($patch->get_release(), $to)) {
                 continue;
             }
             $n = 0;
             do {
                 $key = $patch->get_release() . '.' . $n;
                 $n++;
             } while (isset($list_patches[$key]));
             $list_patches[$key] = $patch;
         }
     }
     uasort($list_patches, function (\patchInterface $patch1, \patchInterface $patch2) {
         return version::lt($patch1->get_release(), $patch2->get_release()) ? -1 : 1;
     });
     $success = true;
     // disable mail
     $this->app['swiftmailer.transport'] = null;
     foreach ($list_patches as $patch) {
         // Gets doctrine migrations required for current patch
         foreach ($patch->getDoctrineMigrations() as $doctrineVersion) {
             /** @var \Doctrine\DBAL\Migrations\Version $version */
             $version = $this->app['doctrine-migration.configuration']->getVersion($doctrineVersion);
             // Skip if already migrated
             if ($version->isMigrated()) {
                 continue;
             }
             $migration = $version->getMigration();
             // Handle legacy migrations
             if ($migration instanceof AbstractMigration) {
                 // Inject entity manager
                 $migration->setEntityManager($this->app['orm.em']);
                 // Execute migration if not marked as migrated and not already applied by an older patch
                 if (!$migration->isAlreadyApplied()) {
                     $version->execute('up');
                     continue;
                 }
                 // Or mark it as migrated
                 $version->markMigrated();
             } else {
                 $version->execute('up');
             }
         }
         if (false === $patch->apply($base, $this->app)) {
             $success = false;
         }
     }
     return $success;
 }
示例#8
0
 /**
  * getSortedVersions method
  * @return Ref[]
  */
 public function getSortedVersions()
 {
     return collect($this->versions)->sort(function (version $v1, version $v2) {
         return version::gt($v1, $v2) ? -1 : 1;
     })->toArray();
 }