diff --git a/composer.json b/composer.json index d9b925fa..80aa680e 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,6 @@ ], "require": { "php": "^7.2", - "abraham/twitteroauth": "^1.0", "algolia/algoliasearch-client-php": "^1.27", "cache/doctrine-adapter": "^1.0", "doctrine/inflector": "^1.4", diff --git a/composer.lock b/composer.lock index 18e41d1c..c5a67327 100644 --- a/composer.lock +++ b/composer.lock @@ -4,62 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7832a4005c54f88d398611a57376aafa", + "content-hash": "68ac21927e0c58d0a1ad8c3ba13b43ba", "packages": [ - { - "name": "abraham/twitteroauth", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/abraham/twitteroauth.git", - "reference": "d54b71c2eee94252154e7b50656e17422fa0b9e1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/abraham/twitteroauth/zipball/d54b71c2eee94252154e7b50656e17422fa0b9e1", - "reference": "d54b71c2eee94252154e7b50656e17422fa0b9e1", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": "^7.2 || ^7.3" - }, - "require-dev": { - "phpmd/phpmd": "~2.6", - "phpunit/phpunit": "~5.7", - "squizlabs/php_codesniffer": "~3.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Abraham\\TwitterOAuth\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Abraham Williams", - "email": "abraham@abrah.am", - "homepage": "https://abrah.am", - "role": "Developer" - } - ], - "description": "The most popular PHP library for use with the Twitter OAuth REST API.", - "homepage": "https://twitteroauth.com", - "keywords": [ - "Twitter API", - "Twitter oAuth", - "api", - "oauth", - "rest", - "social", - "twitter" - ], - "time": "2019-11-29T14:55:32+00:00" - }, { "name": "algolia/algoliasearch-client-php", "version": "1.28.1", diff --git a/config/config.yml b/config/config.yml index 740a915a..5b142ee6 100644 --- a/config/config.yml +++ b/config/config.yml @@ -2,11 +2,6 @@ parameters: doctrine.website.algolia.app_id: 'YVYTFT9XMW' doctrine.website.stripe.publishable_key: 'pk_test_V7rmF8ac3GbakeSJYvp4u0a8003RPO66vC' - doctrine.website.twitter.consumer_key: '' - doctrine.website.twitter.consumer_secret: '' - doctrine.website.twitter.oauth_token: '' - doctrine.website.twitter.oauth_token_secret: '' - doctrine.website.webpack_build_dir: '%doctrine.website.root_dir%/.webpack-build' doctrine.website.projects_dir: '%doctrine.website.root_dir%/projects' doctrine.website.docs_dir: '%doctrine.website.cache_dir%/docs' diff --git a/config/services.xml b/config/services.xml index 1076d35e..841a9875 100644 --- a/config/services.xml +++ b/config/services.xml @@ -550,12 +550,5 @@ %doctrine.website.root_dir%/lib/Migrations - - - %doctrine.website.twitter.consumer_key% - %doctrine.website.twitter.consumer_secret% - %doctrine.website.twitter.oauth_token% - %doctrine.website.twitter.oauth_token_secret% - diff --git a/lib/Application.php b/lib/Application.php index e29709c7..58c3e33e 100644 --- a/lib/Application.php +++ b/lib/Application.php @@ -13,7 +13,6 @@ use Doctrine\ORM\EntityManager; use Doctrine\ORM\Tools\Console\Command as ORMCommand; use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; -use Doctrine\Website\Commands\AnnounceReleaseCommand; use Doctrine\Website\Commands\BuildAllCommand; use Doctrine\Website\Commands\BuildDocsCommand; use Doctrine\Website\Commands\BuildWebsiteCommand; @@ -57,8 +56,7 @@ public function __construct( BuildWebsiteDataCommand $buildWebsiteDataCommand, ClearBuildCacheCommand $clearBuildCacheCommand, SyncRepositoriesCommand $syncRepositoriesCommand, - EventParticipantsCommand $eventParticipantsCommand, - AnnounceReleaseCommand $announceReleaseCommand + EventParticipantsCommand $eventParticipantsCommand ) { $this->application = $application; @@ -69,7 +67,6 @@ public function __construct( $this->application->add($clearBuildCacheCommand); $this->application->add($syncRepositoriesCommand); $this->application->add($eventParticipantsCommand); - $this->application->add($announceReleaseCommand); $this->application->setHelperSet(new HelperSet([ 'question' => new QuestionHelper(), diff --git a/lib/Commands/AnnounceReleaseCommand.php b/lib/Commands/AnnounceReleaseCommand.php deleted file mode 100644 index 9de8a31e..00000000 --- a/lib/Commands/AnnounceReleaseCommand.php +++ /dev/null @@ -1,72 +0,0 @@ -announceRelease = $announceRelease; - - parent::__construct(); - } - - protected function configure(): void - { - $this - ->setDescription('Announce a release on Twitter, Slack, etc.') - ->addArgument( - 'project', - InputArgument::OPTIONAL, - 'The project slug.' - ) - ->addArgument( - 'tag', - InputArgument::OPTIONAL, - 'The tag slug.' - ); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $projectSlug = $input->getArgument('project'); - assert(is_string($projectSlug)); - - $tagSlug = $input->getArgument('tag'); - assert(is_string($tagSlug)); - - try { - $this->announceRelease->__invoke($projectSlug, $tagSlug); - } catch (Throwable $e) { - $output->writeln(sprintf( - 'Failed to announce release! Failed with error: %s', - $e->getMessage() - )); - - return 1; - } - - $output->writeln('Successfully announced release!'); - - return 0; - } -} diff --git a/lib/Release/AnnounceRelease.php b/lib/Release/AnnounceRelease.php deleted file mode 100644 index e47c4c9f..00000000 --- a/lib/Release/AnnounceRelease.php +++ /dev/null @@ -1,54 +0,0 @@ -projectRepository = $projectRepository; - $this->tweetRelease = $tweetRelease; - } - - public function __invoke(string $projectSlug, string $tag): bool - { - $project = $this->projectRepository->findOneBySlug($projectSlug); - - $tagSlug = ltrim($tag, 'v'); - - $e = explode('.', $tagSlug); - - if (count($e) !== 3) { - throw new InvalidArgumentException( - sprintf('Tag "%s" improperly formatted. Expected format "1.0.0".', $tag) - ); - } - - $versionSlug = sprintf('%d.%d', $e[0], $e[1]); - - $version = $project->getVersion($versionSlug); - - $tag = $version->getTag($tagSlug); - - return $this->tweetRelease->__invoke($project, $version, $tag); - } -} diff --git a/lib/Twitter/CreateTweet.php b/lib/Twitter/CreateTweet.php deleted file mode 100644 index ae52939e..00000000 --- a/lib/Twitter/CreateTweet.php +++ /dev/null @@ -1,10 +0,0 @@ -createTweet = $createTweet; - $this->router = $router; - } - - public function __invoke( - Project $project, - ProjectVersion $projectVersion, - Tag $tag - ): bool { - $message = sprintf( - 'Released Doctrine %s %s %s', - $project->getShortName(), - $tag->getDisplayName(), - $this->router->generate('project_version', [ - 'slug' => $project->getSlug(), - 'versionSlug' => $projectVersion->getSlug(), - ], UrlGeneratorInterface::ABSOLUTE_URL) - ); - - return $this->createTweet->__invoke($message); - } -} diff --git a/lib/Twitter/TwitterOAuthCreateTweet.php b/lib/Twitter/TwitterOAuthCreateTweet.php deleted file mode 100644 index 6420a056..00000000 --- a/lib/Twitter/TwitterOAuthCreateTweet.php +++ /dev/null @@ -1,35 +0,0 @@ -twitter = $twitter; - } - - public function __invoke(string $message): bool - { - $result = (array) $this->twitter->post('statuses/update', ['status' => $message]); - - if (isset($result['id'])) { - return true; - } - - throw new RuntimeException( - sprintf('Failed to create tweet: %s', json_encode($result)) - ); - } -} diff --git a/tests/Command/AnnounceReleaseCommandTest.php b/tests/Command/AnnounceReleaseCommandTest.php deleted file mode 100644 index 3f9a5a08..00000000 --- a/tests/Command/AnnounceReleaseCommandTest.php +++ /dev/null @@ -1,133 +0,0 @@ -projectRepository->expects(self::once()) - ->method('findOneBySlug') - ->with('orm') - ->willReturn($this->project); - - $this->router->expects(self::once()) - ->method('generate') - ->with('project_version', [ - 'slug' => 'orm', - 'versionSlug' => '3.0', - ]) - ->willReturn('http://www.url.com'); - - $this->createTweet->expects(self::once()) - ->method('__invoke') - ->with('Released Doctrine ORM 3.0.0 http://www.url.com') - ->willReturn(true); - - self::assertSame(0, $this->commandTester->execute([ - 'project' => 'orm', - 'tag' => '3.0.0', - ])); - - self::assertEquals('Successfully announced release!', trim($this->commandTester->getDisplay())); - } - - public function testExecuteFailure(): void - { - $this->projectRepository->expects(self::once()) - ->method('findOneBySlug') - ->with('orm') - ->willReturn($this->project); - - $this->router->expects(self::once()) - ->method('generate') - ->with('project_version', [ - 'slug' => 'orm', - 'versionSlug' => '3.0', - ]) - ->willReturn('http://www.url.com'); - - $this->createTweet->expects(self::once()) - ->method('__invoke') - ->with('Released Doctrine ORM 3.0.0 http://www.url.com') - ->will(self::throwException(new RuntimeException('test'))); - - self::assertSame(1, $this->commandTester->execute([ - 'project' => 'orm', - 'tag' => '3.0.0', - ])); - - self::assertEquals( - 'Failed to announce release! Failed with error: test', - trim($this->commandTester->getDisplay()) - ); - } - - protected function setUp(): void - { - $this->project = $this->createProject([ - 'slug' => 'orm', - 'shortName' => 'ORM', - 'versions' => [ - [ - 'slug' => '3.0', - 'tags' => [ - [ - 'name' => 'v3.0.0', - 'date' => '2019-09-01', - ], - ], - ], - ], - ]); - - $this->createTweet = $this->createMock(CreateTweet::class); - $this->router = $this->createMock(Router::class); - $this->projectRepository = $this->createMock(ProjectRepository::class); - - $this->tweetRelease = new TweetRelease($this->createTweet, $this->router); - $this->announceRelease = new AnnounceRelease($this->projectRepository, $this->tweetRelease); - $this->command = new AnnounceReleaseCommand($this->announceRelease); - $this->commandTester = new CommandTester($this->command); - } -} diff --git a/tests/Twitter/TwitterOAuthCreateTweetTest.php b/tests/Twitter/TwitterOAuthCreateTweetTest.php deleted file mode 100644 index fdd7c7d7..00000000 --- a/tests/Twitter/TwitterOAuthCreateTweetTest.php +++ /dev/null @@ -1,44 +0,0 @@ -createMock(TwitterOAuth::class); - - $twitterOAuth->expects(self::once()) - ->method('post') - ->with('statuses/update', ['status' => $message]) - ->willReturn((object) ['id' => 1]); - - self::assertTrue((new TwitterOAuthCreateTweet($twitterOAuth))->__invoke($message)); - } - - public function testInvokeFailure(): void - { - $message = 'Tweet this!'; - - $twitterOAuth = $this->createMock(TwitterOAuth::class); - - $twitterOAuth->expects(self::once()) - ->method('post') - ->with('statuses/update', ['status' => $message]) - ->willReturn((object) ['message' => 'Failed']); - - self::expectException(RuntimeException::class); - self::expectExceptionMessage('Failed to create tweet: {"message":"Failed"}'); - - (new TwitterOAuthCreateTweet($twitterOAuth))->__invoke($message); - } -}