diff --git a/bin/surf b/bin/surf index ae5cf14f..5ef32fbc 100755 --- a/bin/surf +++ b/bin/surf @@ -8,14 +8,20 @@ * file that was distributed with this source code. */ +use SelfUpdate\SelfUpdateCommand; +use Symfony\Component\DependencyInjection\Container; +use TYPO3\Surf\Cli\Symfony\ConsoleApplication; + requireAutoloader(); $kernel = new \TYPO3\Surf\Cli\Symfony\ConsoleKernel('prod', false); $kernel->boot(); -/** @var \Symfony\Component\DependencyInjection\Container $container */ +/** @var Container $container */ $container = $kernel->getContainer(); +/** @var ConsoleApplication $application */ $application = $container->get(\TYPO3\Surf\Cli\Symfony\ConsoleApplication::class); +$application->add(new SelfUpdateCommand('TYPO3 Surf', $application->getVersion(), 'typo3/surf')); $application->run(); function requireAutoloader() @@ -30,7 +36,6 @@ function requireAutoloader() ]; foreach ($autoloadPaths as $path) { if (file_exists($path)) { - /** @noinspection PhpIncludeInspection */ return include $path; } } diff --git a/composer.json b/composer.json index d3790ae7..3b04df0f 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ }, "require": { "php": "^7.4 || ^8.0", + "consolidation/self-update": "^2.1", "guzzlehttp/guzzle": "^6.0 || ^7.0", "monolog/monolog": "^2.9.1", "myclabs/php-enum": "^1.8", diff --git a/composer.lock b/composer.lock index c4282538..1be63df1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d0f4ac698a7905cb5467f3aea19f368f", + "content-hash": "aa8fa9925074169a1deb10599a6b5f66", "packages": [ { "name": "composer/ca-bundle", @@ -82,6 +82,142 @@ ], "time": "2023-01-11T08:27:00+00:00" }, + { + "name": "composer/semver", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", + "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.4", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2022-04-01T19:23:25+00:00" + }, + { + "name": "consolidation/self-update", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/consolidation/self-update.git", + "reference": "714b09fdf0513f83292874bb12de0566066040c2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/self-update/zipball/714b09fdf0513f83292874bb12de0566066040c2", + "reference": "714b09fdf0513f83292874bb12de0566066040c2", + "shasum": "" + }, + "require": { + "composer/semver": "^3.2", + "php": ">=5.5.0", + "symfony/console": "^2.8 || ^3 || ^4 || ^5 || ^6", + "symfony/filesystem": "^2.5 || ^3 || ^4 || ^5 || ^6" + }, + "bin": [ + "scripts/release" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "SelfUpdate\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alexander Menk", + "email": "menk@mestrona.net" + }, + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + } + ], + "description": "Provides a self:update command for Symfony Console applications.", + "support": { + "issues": "https://github.com/consolidation/self-update/issues", + "source": "https://github.com/consolidation/self-update/tree/2.1.0" + }, + "time": "2023-02-21T19:33:55+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "7.5.0", @@ -1234,16 +1370,16 @@ }, { "name": "symfony/console", - "version": "v5.4.21", + "version": "v5.4.22", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c77433ddc6cdc689caf48065d9ea22ca0853fbd9" + "reference": "3cd51fd2e6c461ca678f84d419461281bd87a0a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c77433ddc6cdc689caf48065d9ea22ca0853fbd9", - "reference": "c77433ddc6cdc689caf48065d9ea22ca0853fbd9", + "url": "https://api.github.com/repos/symfony/console/zipball/3cd51fd2e6c461ca678f84d419461281bd87a0a8", + "reference": "3cd51fd2e6c461ca678f84d419461281bd87a0a8", "shasum": "" }, "require": { @@ -1308,12 +1444,12 @@ "homepage": "https://symfony.com", "keywords": [ "cli", - "command line", + "command-line", "console", "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.21" + "source": "https://github.com/symfony/console/tree/v5.4.22" }, "funding": [ { @@ -1329,20 +1465,20 @@ "type": "tidelift" } ], - "time": "2023-02-25T16:59:41+00:00" + "time": "2023-03-25T09:27:28+00:00" }, { "name": "symfony/dependency-injection", - "version": "v5.4.21", + "version": "v5.4.22", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "5bc403d96622cf0091abd92c939eadecd4d07f94" + "reference": "e1b7c1432efb4ad1dd89d62906187271e2601ed9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/5bc403d96622cf0091abd92c939eadecd4d07f94", - "reference": "5bc403d96622cf0091abd92c939eadecd4d07f94", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e1b7c1432efb4ad1dd89d62906187271e2601ed9", + "reference": "e1b7c1432efb4ad1dd89d62906187271e2601ed9", "shasum": "" }, "require": { @@ -1402,7 +1538,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v5.4.21" + "source": "https://github.com/symfony/dependency-injection/tree/v5.4.22" }, "funding": [ { @@ -1418,7 +1554,7 @@ "type": "tidelift" } ], - "time": "2023-02-16T09:33:00+00:00" + "time": "2023-03-10T10:02:45+00:00" }, { "name": "symfony/deprecation-contracts", @@ -1560,16 +1696,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v5.4.21", + "version": "v5.4.22", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "f0ae1383a8285dfc6752b8d8602790953118ff5a" + "reference": "1df20e45d56da29a4b1d8259dd6e950acbf1b13f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/f0ae1383a8285dfc6752b8d8602790953118ff5a", - "reference": "f0ae1383a8285dfc6752b8d8602790953118ff5a", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/1df20e45d56da29a4b1d8259dd6e950acbf1b13f", + "reference": "1df20e45d56da29a4b1d8259dd6e950acbf1b13f", "shasum": "" }, "require": { @@ -1625,7 +1761,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.21" + "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.22" }, "funding": [ { @@ -1641,7 +1777,7 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:03:56+00:00" + "time": "2023-03-17T11:31:58+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -1851,16 +1987,16 @@ }, { "name": "symfony/http-foundation", - "version": "v5.4.21", + "version": "v5.4.22", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "3bb6ee5582366c4176d5ce596b380117c8200bbf" + "reference": "05cd1acdd0e3ce8473aaba1d86c188321d85f313" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/3bb6ee5582366c4176d5ce596b380117c8200bbf", - "reference": "3bb6ee5582366c4176d5ce596b380117c8200bbf", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/05cd1acdd0e3ce8473aaba1d86c188321d85f313", + "reference": "05cd1acdd0e3ce8473aaba1d86c188321d85f313", "shasum": "" }, "require": { @@ -1907,7 +2043,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v5.4.21" + "source": "https://github.com/symfony/http-foundation/tree/v5.4.22" }, "funding": [ { @@ -1923,20 +2059,20 @@ "type": "tidelift" } ], - "time": "2023-02-17T21:35:35+00:00" + "time": "2023-03-28T07:28:17+00:00" }, { "name": "symfony/http-kernel", - "version": "v5.4.21", + "version": "v5.4.22", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "09c19fc7e4218fbcf73fe0330eea38d66064b775" + "reference": "2d3a8be2c756353627398827c409af6f126c096d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/09c19fc7e4218fbcf73fe0330eea38d66064b775", - "reference": "09c19fc7e4218fbcf73fe0330eea38d66064b775", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/2d3a8be2c756353627398827c409af6f126c096d", + "reference": "2d3a8be2c756353627398827c409af6f126c096d", "shasum": "" }, "require": { @@ -2019,7 +2155,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v5.4.21" + "source": "https://github.com/symfony/http-kernel/tree/v5.4.22" }, "funding": [ { @@ -2035,7 +2171,7 @@ "type": "tidelift" } ], - "time": "2023-02-28T13:19:09+00:00" + "time": "2023-03-31T11:54:37+00:00" }, { "name": "symfony/options-resolver", @@ -2679,16 +2815,16 @@ }, { "name": "symfony/process", - "version": "v5.4.21", + "version": "v5.4.22", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "d4ce417ebcb0b7d090b4c178ed6d3accc518e8bd" + "reference": "4b850da0cc3a2a9181c1ed407adbca4733dc839b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/d4ce417ebcb0b7d090b4c178ed6d3accc518e8bd", - "reference": "d4ce417ebcb0b7d090b4c178ed6d3accc518e8bd", + "url": "https://api.github.com/repos/symfony/process/zipball/4b850da0cc3a2a9181c1ed407adbca4733dc839b", + "reference": "4b850da0cc3a2a9181c1ed407adbca4733dc839b", "shasum": "" }, "require": { @@ -2721,7 +2857,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.21" + "source": "https://github.com/symfony/process/tree/v5.4.22" }, "funding": [ { @@ -2737,7 +2873,7 @@ "type": "tidelift" } ], - "time": "2023-02-21T19:46:44+00:00" + "time": "2023-03-06T21:29:33+00:00" }, { "name": "symfony/service-contracts", @@ -2824,16 +2960,16 @@ }, { "name": "symfony/string", - "version": "v5.4.21", + "version": "v5.4.22", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "edac10d167b78b1d90f46a80320d632de0bd9f2f" + "reference": "8036a4c76c0dd29e60b6a7cafcacc50cf088ea62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/edac10d167b78b1d90f46a80320d632de0bd9f2f", - "reference": "edac10d167b78b1d90f46a80320d632de0bd9f2f", + "url": "https://api.github.com/repos/symfony/string/zipball/8036a4c76c0dd29e60b6a7cafcacc50cf088ea62", + "reference": "8036a4c76c0dd29e60b6a7cafcacc50cf088ea62", "shasum": "" }, "require": { @@ -2890,7 +3026,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.21" + "source": "https://github.com/symfony/string/tree/v5.4.22" }, "funding": [ { @@ -2906,20 +3042,20 @@ "type": "tidelift" } ], - "time": "2023-02-22T08:00:55+00:00" + "time": "2023-03-14T06:11:53+00:00" }, { "name": "symfony/var-dumper", - "version": "v5.4.21", + "version": "v5.4.22", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "6c5ac3a1be8b849d59a1a77877ee110e1b55eb74" + "reference": "e2edac9ce47e6df07e38143c7cfa6bdbc1a6dcc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/6c5ac3a1be8b849d59a1a77877ee110e1b55eb74", - "reference": "6c5ac3a1be8b849d59a1a77877ee110e1b55eb74", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/e2edac9ce47e6df07e38143c7cfa6bdbc1a6dcc4", + "reference": "e2edac9ce47e6df07e38143c7cfa6bdbc1a6dcc4", "shasum": "" }, "require": { @@ -2979,7 +3115,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v5.4.21" + "source": "https://github.com/symfony/var-dumper/tree/v5.4.22" }, "funding": [ { @@ -2995,7 +3131,7 @@ "type": "tidelift" } ], - "time": "2023-02-23T10:00:28+00:00" + "time": "2023-03-25T09:27:28+00:00" }, { "name": "webmozart/assert", @@ -3128,87 +3264,6 @@ ], "time": "2022-11-17T09:50:14+00:00" }, - { - "name": "composer/semver", - "version": "3.3.2", - "source": { - "type": "git", - "url": "https://github.com/composer/semver.git", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.4", - "symfony/phpunit-bridge": "^4.2 || ^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Semver\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nils Adermann", - "email": "naderman@naderman.de", - "homepage": "http://www.naderman.de" - }, - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - }, - { - "name": "Rob Bast", - "email": "rob.bast@gmail.com", - "homepage": "http://robbast.nl" - } - ], - "description": "Semver library that offers utilities, version constraint parsing and validation.", - "keywords": [ - "semantic", - "semver", - "validation", - "versioning" - ], - "support": { - "irc": "irc://irc.freenode.org/composer", - "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.3.2" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2022-04-01T19:23:25+00:00" - }, { "name": "composer/xdebug-handler", "version": "3.0.3", diff --git a/src/Command/SelfUpdateCommand.php b/src/Command/SelfUpdateCommand.php deleted file mode 100755 index 41413670..00000000 --- a/src/Command/SelfUpdateCommand.php +++ /dev/null @@ -1,122 +0,0 @@ -addOption( - 'stability', - null, - InputOption::VALUE_OPTIONAL, - 'GitHub stability value (' . GithubStrategy::STABLE . ', ' . GithubStrategy::UNSTABLE . ', ' . GithubStrategy::ANY . ')', - GithubStrategy::STABLE - )->addOption( - 'check', - null, - InputOption::VALUE_NONE, - 'Check for new version' - )->addOption( - 'rollback', - null, - InputOption::VALUE_NONE, - 'Rolls back to previous version' - )->setDescription(sprintf('Update %s to most recent stable build', $this->getLocalPharName())); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $updater = new Updater(null, false, Updater::STRATEGY_GITHUB); - /** @var GithubStrategy $strategy */ - $strategy = $updater->getStrategy(); - $strategy->setPackageName('typo3/surf'); - $strategy->setPharName('surf.phar'); - - $io = new SymfonyStyle($input, $output); - - $stability = $input->getOption('stability'); - - $application = $this->getApplication(); - - if (! $application instanceof Application) { - throw new UnexpectedValueException('No application defined'); - } - - $strategy->setCurrentLocalVersion($application->getVersion()); - $strategy->setStability($stability); - - if ($input->getOption('check')) { - $result = $updater->hasUpdate(); - if ($result) { - $output->writeln(sprintf( - 'The %s build available remotely is: %s', - $strategy->getStability() === GithubStrategy::ANY ? 'latest' : 'current ' . $strategy->getStability(), - $updater->getNewVersion() - )); - } elseif ('' === $updater->getNewVersion()) { - $output->writeln('There are no new builds available.'); - } else { - $output->writeln(sprintf('You have the current %s build installed.', $strategy->getStability())); - } - } elseif ($input->getOption('rollback')) { - $result = $updater->rollback(); - $result ? $output->writeln('Success!') : $output->writeln('Failure!'); - } else { - $result = $updater->update(); - - if ($result) { - $io->success( - sprintf( - 'Your %s has been updated from "%s" to "%s".', - $this->getLocalPharName(), - $updater->getOldVersion(), - $updater->getNewVersion() - ) - ); - } else { - $io->success(sprintf('Your %s is already up to date.', $this->getLocalPharName())); - } - } - - return Command::SUCCESS; - } - - private function getLocalPharName(): string - { - return basename(Phar::running()); - } -}