diff --git a/README.md b/README.md index f13200f9a..52607181e 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ OpenCFP comes bundled with a few command-line utilities to administer the system can be found by running the following in the project root: ``` -$ bin/opencfp +$ bin/console ``` ### [Admin Group Management](#admin-group-management) @@ -256,13 +256,13 @@ Administrators are authorized to review speaker information in addition to speci Adding `speaker@opencfp.org` to the admin group: ``` -$ bin/opencfp user:promote --env=production speaker@opencfp.org admin +$ bin/console user:promote --env=production speaker@opencfp.org admin ``` Removing `speaker@opencfp.org` from the admin group: ``` -$ bin/opencfp user:demote --env=production speaker@opencfp.org admin +$ bin/console user:demote --env=production speaker@opencfp.org admin ``` ### [Reviewer Group Management](#reviewer-group-management) @@ -271,13 +271,13 @@ Reviewers are authorized to see talks and give ratings to them. Adding `speaker@opencfp.org` to the reviewer group: ``` -$ bin/opencfp user:promote --env=production speaker@opencfp.org reviewer +$ bin/console user:promote --env=production speaker@opencfp.org reviewer ``` Removing `speaker@opencfp.org` from the reviewer group: ``` -$ bin/opencfp user:demote --env=production speaker@opencfp.org reviewer +$ bin/console user:demote --env=production speaker@opencfp.org reviewer ``` @@ -288,19 +288,19 @@ Users are needed for you system, and sometimes you want to add users via command Adding a speaker: ``` -$ bin/opencfp user:create --first_name="Speaker" --last_name="Name" --email="speaker@opencfp.org" --password="somePassw0rd!" +$ bin/console user:create --first_name="Speaker" --last_name="Name" --email="speaker@opencfp.org" --password="somePassw0rd!" ``` Add an admin: ``` -$ bin/opencfp user:create --first_name="Admin" --last_name="Name" --email="admin@opencfp.org" --password="somePassw0rd!" --admin +$ bin/console user:create --first_name="Admin" --last_name="Name" --email="admin@opencfp.org" --password="somePassw0rd!" --admin ``` Add a reviewer: ``` -$ bin/opencfp user:create --first_name="Admin" --last_name="Name" --email="admin@opencfp.org" --password="somePassw0rd!" --reviewer +$ bin/console user:create --first_name="Admin" --last_name="Name" --email="admin@opencfp.org" --password="somePassw0rd!" --reviewer ``` ### [Clear Caches](#clear-caches) @@ -309,7 +309,7 @@ OpenCFP uses Twig as a templating engine and HTML Purifier for input filtering. If you need to clear all application caches: ``` -$ bin/opencfp cache:clear +$ bin/console cache:clear ``` ### [Scripts to Rule Them All](#scripts-rule-all) @@ -348,7 +348,7 @@ $ script/test ## [Compiling Frontend Assets](#compiling-frontend-assets) -OpenCFP ships with a pre-compiled CSS file. However, we now include the Sass / PostCSS used to compile front-end assets. You are free to modify these source files to change brand colors or modify your instance however you see fit. Remember, you can do **nothing** and take advantage of the pre-compiled CSS we ship. You only need these instructions if you want to customize or contribute to the look and feel of OpenCFP. Let's take a look at this new workflow for OpenCFP. +OpenCFP ships with a pre-compiled CSS file. However, we now include the Sass / PostCSS used to compile front-end assets. You are free to modify these source files to change brand colors or modify your instance however you see fit. Remember, you can do **nothing** and take advantage of the pre-compiled CSS we ship. You only need these instructions if you want to customize or contribute to the look and feel of OpenCFP. Let's take a look at this new workflow for OpenCFP. Install Node dependencies using `yarn`. @@ -360,7 +360,7 @@ Now dependencies are installed and we're ready to compile assets. Check out the The main `app.scss` file is at [`resources/assets/sass/app.scss`](resources/assets/sass/app.scss). We use [Laravel Mix](https://github.com/JeffreyWay/laravel-mix) to compile our Sass. Mix is configurable to run without Laravel, so we take advantage of that because it really makes dealing with Webpack a lot simpler. Our Mix configuration is at [`webpack.mix.js`](webpack.mix.js). In it, we run our `app.scss` through a Sass compilation step, we copy FontAwesome icons and finally run the compiled CSS through [Tailwind CSS](https://tailwindcss.com), a PostCSS plugin. -TailwindCSS is a new utility-first CSS framework that uses CSS class composition to piece together interfaces. Check out [their documentation](https://tailwindcss.com/docs/what-is-tailwind/) for more information on how to use the framework. We use it extensively across OpenCFP and it saves a lot of time and keeps us from having to maintain *too much* CSS. If you take a look through our `app.scss`, you'll see a lot of calls to [`@apply`](https://tailwindcss.com/docs/functions-and-directives#apply). This is NOT a Sass construct. It's a TailwindCSS function used to mixin existing classes into our custom CSS. +TailwindCSS is a new utility-first CSS framework that uses CSS class composition to piece together interfaces. Check out [their documentation](https://tailwindcss.com/docs/what-is-tailwind/) for more information on how to use the framework. We use it extensively across OpenCFP and it saves a lot of time and keeps us from having to maintain *too much* CSS. If you take a look through our `app.scss`, you'll see a lot of calls to [`@apply`](https://tailwindcss.com/docs/functions-and-directives#apply). This is NOT a Sass construct. It's a TailwindCSS function used to mixin existing classes into our custom CSS. ## [Testing](#testing) diff --git a/bin/console b/bin/console new file mode 100755 index 000000000..56d36f5b5 --- /dev/null +++ b/bin/console @@ -0,0 +1,23 @@ +#!/usr/bin/env php +getParameterOption(['--env'], \getenv('CFP_ENV') ?: 'development')); + +if (!$environment->isProduction()) { + Debug::enable(); +} + +$kernel = new Kernel((string) $environment, !$environment->isProduction()); +$application = new Application($kernel); +$application->run($input); diff --git a/bin/opencfp b/bin/opencfp deleted file mode 100755 index 9992309c5..000000000 --- a/bin/opencfp +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env php -getParameterOption(['--env'], \getenv('CFP_ENV') ?: 'development')); - -$kernel = new Kernel((string) $environment, !$environment->isProduction()); -$kernel->boot(); - -/** @var Console\Application $app */ -$app = $kernel->getContainer()->get(Console\Application::class); - -$status = $app->run($input); - -exit($status); diff --git a/classes/Console/Command/ClearCacheCommand.php b/classes/Console/Command/ClearCacheCommand.php deleted file mode 100644 index cad800ac3..000000000 --- a/classes/Console/Command/ClearCacheCommand.php +++ /dev/null @@ -1,104 +0,0 @@ -paths = $paths; - } - - protected function configure() - { - $this->setDescription('Clears the caches'); - } - - public function execute(InputInterface $input, OutputInterface $output) - { - $io = new SymfonyStyle( - $input, - $output - ); - - $io->title('OpenCFP'); - - $io->section('Clearing caches'); - - \array_walk($this->paths, function ($path) use ($io) { - $count = $this->deleteFilesAndDirectoriesIn($path); - - $io->writeln(\sprintf( - ' * %s (%d files and directories)', - $path, - $count - )); - }); - - $io->success('Cleared caches.'); - } - - private function deleteFilesAndDirectoriesIn(string $path): int - { - $count = 0; - - try { - $filesAndDirectories = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator( - $path, - \RecursiveDirectoryIterator::SKIP_DOTS - ), - \RecursiveIteratorIterator::CHILD_FIRST - ); - } catch (\UnexpectedValueException $e) { - return 0; - } - - foreach ($filesAndDirectories as $fileInfo) { - if ($this->delete($fileInfo)) { - ++$count; - } - } - - return $count; - } - - private function delete(\SplFileInfo $fileInfo): bool - { - $filePath = (string) $fileInfo; - - /** @var \SplFileInfo $fileInfo */ - if ($fileInfo->isDir()) { - return \rmdir($filePath); - } - - if ($fileInfo->isFile()) { - return \unlink($filePath); - } - - return false; - } -} diff --git a/resources/config/services/console.yml b/resources/config/services/console.yml index 110c1e422..54e59436f 100644 --- a/resources/config/services/console.yml +++ b/resources/config/services/console.yml @@ -5,17 +5,14 @@ services: OpenCFP\Console\Command\: resource: '%kernel.project_dir%/classes/Console/Command/*' - - OpenCFP\Console\Command\ClearCacheCommand: - arguments: - $paths: ['%kernel.cache_dir%'] + tags: + - { name: console.command } OpenCFP\Console\Application: public: true autowire: false calls: - [setDispatcher, ['@event_dispatcher']] - - [add, ['@OpenCFP\Console\Command\ClearCacheCommand']] - [add, ['@OpenCFP\Console\Command\UserCreateCommand']] - [add, ['@OpenCFP\Console\Command\UserDemoteCommand']] - [add, ['@OpenCFP\Console\Command\UserPromoteCommand']] diff --git a/script/update b/script/update index ebe778a39..752e8cd9a 100755 --- a/script/update +++ b/script/update @@ -13,7 +13,7 @@ if [ "$CFP_ENV" = "" ]; then fi echo "==> Clearing cache..." -bin/opencfp cache:clear +bin/console cache:clear echo "==> Updating db..." # run all database migrations to ensure everything is up to date. diff --git a/tests/Unit/Console/Command/ClearCacheCommandTest.php b/tests/Unit/Console/Command/ClearCacheCommandTest.php deleted file mode 100644 index 590f8c96d..000000000 --- a/tests/Unit/Console/Command/ClearCacheCommandTest.php +++ /dev/null @@ -1,147 +0,0 @@ -root = vfs\vfsStream::setup('cache'); - } - - public function testIsFinal() - { - $this->assertClassIsFinal(ClearCacheCommand::class); - } - - public function testExtendsCommand() - { - $this->assertClassExtends(Console\Command\Command::class, ClearCacheCommand::class); - } - - public function testHasNameAndDescription() - { - $command = new ClearCacheCommand([]); - - $this->assertSame('cache:clear', $command->getName()); - $this->assertSame('Clears the caches', $command->getDescription()); - } - - public function testExecuteRemovesFilesWithinCacheDirectories() - { - $directories = [ - $this->createDirectoryWithFilesAndDirectories($this->root->url()), - $this->createDirectoryWithFilesAndDirectories($this->root->url()), - ]; - - $command = new ClearCacheCommand($directories); - - $commandTester = new Console\Tester\CommandTester($command); - - $commandTester->execute([]); - - $this->assertSame(0, $commandTester->getStatusCode()); - - $this->assertContains('Clearing caches', $commandTester->getDisplay()); - $this->assertContains('Cleared caches', $commandTester->getDisplay()); - - foreach ($directories as $directory) { - $this->assertDirectoryExists($directory); - - $filesAndDirectories = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator( - $directory, - \RecursiveDirectoryIterator::SKIP_DOTS - ), - \RecursiveIteratorIterator::CHILD_FIRST - ); - - $this->assertCount(0, $filesAndDirectories); - } - } - - private function createDirectoryWithFilesAndDirectories(string $rootDirectory, int $currentDepth = 0, $maxDepth = 3) - { - $directory = $this->createDirectory($rootDirectory); - - for ($i = 0; $i < 5; ++$i) { - $this->createFile($directory); - } - - if ($currentDepth < $maxDepth) { - return $this->createDirectoryWithFilesAndDirectories($directory, ++$currentDepth); - } - - return $directory; - } - - private function createDirectory(string $rootDirectory): string - { - $directory = \sprintf( - '%s/%s', - $rootDirectory, - $this->faker()->word - ); - - \mkdir($directory, 0777, true); - - return $directory; - } - - private function createFile(string $parentDirectory) - { - $fileName = $this->createFileName(); - - $filePath = \sprintf( - '%s/%s', - $parentDirectory, - $fileName - ); - - \file_put_contents( - $filePath, - $this->faker()->text - ); - } - - private function createFileName(): string - { - $faker = $this->faker(); - - $withExtension = $faker->boolean; - - if ($withExtension) { - return \sprintf( - '%s.%s', - $faker->unique()->word, - $faker->fileExtension - ); - } - - return $faker->unique()->word; - } -}