From a65ce649ac85267301997bb8fb8fd4dd6d156822 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 29 Sep 2018 09:52:32 +0200 Subject: [PATCH 1/7] Created new Installer module and moved everything from CLI there --- bin/install | 4 ++-- bin/update | 4 ++-- composer.json | 10 ++++++---- config/config.php | 16 +++------------- module/CLI/config/cli.config.php | 7 ++++--- module/CLI/config/dependencies.config.php | 6 +++--- module/Installer/config/translator.config.php | 16 ++++++++++++++++ .../src/Command}/InstallCommand.php | 12 ++++++------ .../src/Config}/ConfigCustomizerManager.php | 4 ++-- .../Config}/ConfigCustomizerManagerInterface.php | 2 +- .../Plugin/ApplicationConfigCustomizer.php | 4 ++-- .../Config}/Plugin/ConfigCustomizerInterface.php | 4 ++-- .../Config}/Plugin/DatabaseConfigCustomizer.php | 7 ++++--- .../Config}/Plugin/LanguageConfigCustomizer.php | 9 +++++---- .../Plugin/UrlShortenerConfigCustomizer.php | 7 ++++--- module/Installer/src/ConfigProvider.php | 15 +++++++++++++++ .../src/Factory/InstallApplicationFactory.php | 8 ++++---- .../src/Model/CustomizableAppConfig.php | 4 ++-- .../config/params/generated_config.php | 0 .../test/Command}/InstallCommandTest.php | 12 ++++++------ .../Plugin/ApplicationConfigCustomizerTest.php | 6 +++--- .../Plugin/DatabaseConfigCustomizerTest.php | 6 +++--- .../Plugin/LanguageConfigCustomizerTest.php | 6 +++--- .../Plugin/UrlShortenerConfigCustomizerTest.php | 6 +++--- .../Factory/InstallApplicationFactoryTest.php | 4 ++-- phpunit.xml.dist | 3 +++ 26 files changed, 106 insertions(+), 76 deletions(-) create mode 100644 module/Installer/config/translator.config.php rename module/{CLI/src/Command/Install => Installer/src/Command}/InstallCommand.php (95%) rename module/{CLI/src/Install => Installer/src/Config}/ConfigCustomizerManager.php (68%) rename module/{CLI/src/Install => Installer/src/Config}/ConfigCustomizerManagerInterface.php (76%) rename module/{CLI/src/Install => Installer/src/Config}/Plugin/ApplicationConfigCustomizer.php (92%) rename module/{CLI/src/Install => Installer/src/Config}/Plugin/ConfigCustomizerInterface.php (74%) rename module/{CLI/src/Install => Installer/src/Config}/Plugin/DatabaseConfigCustomizer.php (92%) rename module/{CLI/src/Install => Installer/src/Config}/Plugin/LanguageConfigCustomizer.php (74%) rename module/{CLI/src/Install => Installer/src/Config}/Plugin/UrlShortenerConfigCustomizer.php (86%) create mode 100644 module/Installer/src/ConfigProvider.php rename module/{CLI => Installer}/src/Factory/InstallApplicationFactory.php (90%) rename module/{CLI => Installer}/src/Model/CustomizableAppConfig.php (98%) rename module/{CLI => Installer}/test-resources/config/params/generated_config.php (100%) rename module/{CLI/test/Command/Install => Installer/test/Command}/InstallCommandTest.php (92%) rename module/{CLI/test/Install => Installer/test/Config}/Plugin/ApplicationConfigCustomizerTest.php (92%) rename module/{CLI/test/Install => Installer/test/Config}/Plugin/DatabaseConfigCustomizerTest.php (95%) rename module/{CLI/test/Install => Installer/test/Config}/Plugin/LanguageConfigCustomizerTest.php (92%) rename module/{CLI/test/Install => Installer/test/Config}/Plugin/UrlShortenerConfigCustomizerTest.php (94%) rename module/{CLI => Installer}/test/Factory/InstallApplicationFactoryTest.php (86%) diff --git a/bin/install b/bin/install index 0d8dc72c..66282df0 100755 --- a/bin/install +++ b/bin/install @@ -2,8 +2,8 @@ getMergedConfig(); diff --git a/module/CLI/config/cli.config.php b/module/CLI/config/cli.config.php index 501cb668..fb07cb47 100644 --- a/module/CLI/config/cli.config.php +++ b/module/CLI/config/cli.config.php @@ -1,13 +1,14 @@ [ - 'locale' => Common\env('CLI_LOCALE', 'en'), + 'locale' => env('CLI_LOCALE', 'en'), 'commands' => [ Command\ShortUrl\GenerateShortUrlCommand::NAME => Command\ShortUrl\GenerateShortUrlCommand::class, Command\ShortUrl\ResolveUrlCommand::NAME => Command\ShortUrl\ResolveUrlCommand::class, diff --git a/module/CLI/config/dependencies.config.php b/module/CLI/config/dependencies.config.php index f6f441c6..371c9175 100644 --- a/module/CLI/config/dependencies.config.php +++ b/module/CLI/config/dependencies.config.php @@ -1,8 +1,8 @@ [ 'factories' => [ - Application::class => ApplicationFactory::class, + Application::class => Factory\ApplicationFactory::class, Command\ShortUrl\GenerateShortUrlCommand::class => ConfigAbstractFactory::class, Command\ShortUrl\ResolveUrlCommand::class => ConfigAbstractFactory::class, diff --git a/module/Installer/config/translator.config.php b/module/Installer/config/translator.config.php new file mode 100644 index 00000000..659d4cae --- /dev/null +++ b/module/Installer/config/translator.config.php @@ -0,0 +1,16 @@ + [ + 'translation_file_patterns' => [ + [ + 'type' => 'gettext', + 'base_dir' => __DIR__ . '/../lang', + 'pattern' => '%s.mo', + ], + ], + ], + +]; diff --git a/module/CLI/src/Command/Install/InstallCommand.php b/module/Installer/src/Command/InstallCommand.php similarity index 95% rename from module/CLI/src/Command/Install/InstallCommand.php rename to module/Installer/src/Command/InstallCommand.php index e3ed030c..3e71a065 100644 --- a/module/CLI/src/Command/Install/InstallCommand.php +++ b/module/Installer/src/Command/InstallCommand.php @@ -1,13 +1,13 @@ 'pdo_mysql', 'PostgreSQL' => 'pdo_pgsql', 'SQLite' => 'pdo_sqlite', diff --git a/module/CLI/src/Install/Plugin/LanguageConfigCustomizer.php b/module/Installer/src/Config/Plugin/LanguageConfigCustomizer.php similarity index 74% rename from module/CLI/src/Install/Plugin/LanguageConfigCustomizer.php rename to module/Installer/src/Config/Plugin/LanguageConfigCustomizer.php index 15125d32..64582de8 100644 --- a/module/CLI/src/Install/Plugin/LanguageConfigCustomizer.php +++ b/module/Installer/src/Config/Plugin/LanguageConfigCustomizer.php @@ -1,18 +1,19 @@ $io->confirm('Do you want to validate long urls by 200 HTTP status code on response'), ]); } diff --git a/module/Installer/src/ConfigProvider.php b/module/Installer/src/ConfigProvider.php new file mode 100644 index 00000000..6be4cf16 --- /dev/null +++ b/module/Installer/src/ConfigProvider.php @@ -0,0 +1,15 @@ +filesystem->exists( - __DIR__ . '/../../../test-resources/' . InstallCommand::GENERATED_CONFIG_PATH + __DIR__ . '/../../test-resources/' . InstallCommand::GENERATED_CONFIG_PATH )->willReturn(true); $this->commandTester->setInputs([ '', '/foo/bar/wrong_previous_shlink', '', - __DIR__ . '/../../../test-resources', + __DIR__ . '/../../test-resources', ]); $this->commandTester->execute([]); diff --git a/module/CLI/test/Install/Plugin/ApplicationConfigCustomizerTest.php b/module/Installer/test/Config/Plugin/ApplicationConfigCustomizerTest.php similarity index 92% rename from module/CLI/test/Install/Plugin/ApplicationConfigCustomizerTest.php rename to module/Installer/test/Config/Plugin/ApplicationConfigCustomizerTest.php index 5450d0b1..9a5bc3c5 100644 --- a/module/CLI/test/Install/Plugin/ApplicationConfigCustomizerTest.php +++ b/module/Installer/test/Config/Plugin/ApplicationConfigCustomizerTest.php @@ -1,13 +1,13 @@ ./module/CLI/test + + ./module/Installer/test + From d5392a5f597fcd025006a60c14050c2bb703108f Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 29 Sep 2018 09:55:13 +0200 Subject: [PATCH 2/7] Added missing void return type hint --- .../src/Config/Plugin/ApplicationConfigCustomizer.php | 7 +------ .../src/Config/Plugin/ConfigCustomizerInterface.php | 7 +------ .../src/Config/Plugin/DatabaseConfigCustomizer.php | 6 +----- .../src/Config/Plugin/LanguageConfigCustomizer.php | 8 +------- .../src/Config/Plugin/UrlShortenerConfigCustomizer.php | 7 +------ 5 files changed, 5 insertions(+), 30 deletions(-) diff --git a/module/Installer/src/Config/Plugin/ApplicationConfigCustomizer.php b/module/Installer/src/Config/Plugin/ApplicationConfigCustomizer.php index f29adc15..a57a3f78 100644 --- a/module/Installer/src/Config/Plugin/ApplicationConfigCustomizer.php +++ b/module/Installer/src/Config/Plugin/ApplicationConfigCustomizer.php @@ -11,12 +11,7 @@ class ApplicationConfigCustomizer implements ConfigCustomizerInterface { use StringUtilsTrait; - /** - * @param SymfonyStyle $io - * @param CustomizableAppConfig $appConfig - * @return void - */ - public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig) + public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void { $io->title('APPLICATION'); diff --git a/module/Installer/src/Config/Plugin/ConfigCustomizerInterface.php b/module/Installer/src/Config/Plugin/ConfigCustomizerInterface.php index 015f767b..908f6f90 100644 --- a/module/Installer/src/Config/Plugin/ConfigCustomizerInterface.php +++ b/module/Installer/src/Config/Plugin/ConfigCustomizerInterface.php @@ -8,10 +8,5 @@ use Symfony\Component\Console\Style\SymfonyStyle; interface ConfigCustomizerInterface { - /** - * @param SymfonyStyle $io - * @param CustomizableAppConfig $appConfig - * @return void - */ - public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig); + public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void; } diff --git a/module/Installer/src/Config/Plugin/DatabaseConfigCustomizer.php b/module/Installer/src/Config/Plugin/DatabaseConfigCustomizer.php index 663ffbe0..c117c32d 100644 --- a/module/Installer/src/Config/Plugin/DatabaseConfigCustomizer.php +++ b/module/Installer/src/Config/Plugin/DatabaseConfigCustomizer.php @@ -3,7 +3,6 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Installer\Config\Plugin; -use Shlinkio\Shlink\Installer\Config\Plugin\ConfigCustomizerInterface; use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Filesystem\Exception\IOException; @@ -28,12 +27,9 @@ class DatabaseConfigCustomizer implements ConfigCustomizerInterface } /** - * @param SymfonyStyle $io - * @param CustomizableAppConfig $appConfig - * @return void * @throws IOException */ - public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig) + public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void { $io->title('DATABASE'); diff --git a/module/Installer/src/Config/Plugin/LanguageConfigCustomizer.php b/module/Installer/src/Config/Plugin/LanguageConfigCustomizer.php index 64582de8..1a7a2de4 100644 --- a/module/Installer/src/Config/Plugin/LanguageConfigCustomizer.php +++ b/module/Installer/src/Config/Plugin/LanguageConfigCustomizer.php @@ -3,7 +3,6 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Installer\Config\Plugin; -use Shlinkio\Shlink\Installer\Config\Plugin\ConfigCustomizerInterface; use Shlinkio\Shlink\Installer\Model\CustomizableAppConfig; use Symfony\Component\Console\Style\SymfonyStyle; @@ -11,12 +10,7 @@ class LanguageConfigCustomizer implements ConfigCustomizerInterface { private const SUPPORTED_LANGUAGES = ['en', 'es']; - /** - * @param SymfonyStyle $io - * @param \Shlinkio\Shlink\Installer\Model\CustomizableAppConfig $appConfig - * @return void - */ - public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig) + public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void { $io->title('LANGUAGE'); diff --git a/module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php b/module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php index d3737d66..729ec2f8 100644 --- a/module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php +++ b/module/Installer/src/Config/Plugin/UrlShortenerConfigCustomizer.php @@ -10,12 +10,7 @@ use function str_shuffle; class UrlShortenerConfigCustomizer implements ConfigCustomizerInterface { - /** - * @param SymfonyStyle $io - * @param CustomizableAppConfig $appConfig - * @return void - */ - public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig) + public function process(SymfonyStyle $io, CustomizableAppConfig $appConfig): void { $io->title('URL SHORTENER'); From 1b4343ffc258000c2e0285129ba6c7610db44fd0 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 29 Sep 2018 10:00:17 +0200 Subject: [PATCH 3/7] Moved update and install duplicated code to common config file --- bin/install | 28 +++++----------------------- bin/update | 28 +++++----------------------- config/install-container.php | 29 +++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 46 deletions(-) create mode 100644 config/install-container.php diff --git a/bin/install b/bin/install index 66282df0..13c0a3e8 100755 --- a/bin/install +++ b/bin/install @@ -2,29 +2,11 @@ [ - Application::class => InstallApplicationFactory::class, - Filesystem::class => InvokableFactory::class, - ], - 'services' => [ - 'config' => [ - ConfigAbstractFactory::class => [ - DatabaseConfigCustomizer::class => [Filesystem::class] - ], - ], - ], -]); +/** @var ServiceLocatorInterface $container */ +$container = include __DIR__ . '/../config/install-container.php'; $container->build(Application::class)->run(); diff --git a/bin/update b/bin/update index 92b0f054..8e2e02b5 100755 --- a/bin/update +++ b/bin/update @@ -2,29 +2,11 @@ [ - Application::class => InstallApplicationFactory::class, - Filesystem::class => InvokableFactory::class, - ], - 'services' => [ - 'config' => [ - ConfigAbstractFactory::class => [ - DatabaseConfigCustomizer::class => [Filesystem::class] - ], - ], - ], -]); +/** @var ServiceLocatorInterface $container */ +$container = include __DIR__ . '/../config/install-container.php'; $container->build(Application::class, ['isUpdate' => true])->run(); diff --git a/config/install-container.php b/config/install-container.php new file mode 100644 index 00000000..0db90897 --- /dev/null +++ b/config/install-container.php @@ -0,0 +1,29 @@ + [ + Application::class => InstallApplicationFactory::class, + Filesystem::class => InvokableFactory::class, + ], + 'services' => [ + 'config' => [ + ConfigAbstractFactory::class => [ + DatabaseConfigCustomizer::class => [Filesystem::class], + ], + ], + ], +]); +return $container; From f92cff6241cd5b050506c8cc09e3f66c534a747b Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 29 Sep 2018 10:05:13 +0200 Subject: [PATCH 4/7] Removed not used translator config --- module/Installer/config/module.config.php | 4 ++++ module/Installer/config/translator.config.php | 16 ---------------- 2 files changed, 4 insertions(+), 16 deletions(-) create mode 100644 module/Installer/config/module.config.php delete mode 100644 module/Installer/config/translator.config.php diff --git a/module/Installer/config/module.config.php b/module/Installer/config/module.config.php new file mode 100644 index 00000000..353ace17 --- /dev/null +++ b/module/Installer/config/module.config.php @@ -0,0 +1,4 @@ + [ - 'translation_file_patterns' => [ - [ - 'type' => 'gettext', - 'base_dir' => __DIR__ . '/../lang', - 'pattern' => '%s.mo', - ], - ], - ], - -]; From 49cca5cd696359eb6c0a5816aec75136cfbc1d81 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 29 Sep 2018 10:07:10 +0200 Subject: [PATCH 5/7] Removed FQCN --- module/Installer/src/Command/InstallCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/Installer/src/Command/InstallCommand.php b/module/Installer/src/Command/InstallCommand.php index 3e71a065..dde61aa3 100644 --- a/module/Installer/src/Command/InstallCommand.php +++ b/module/Installer/src/Command/InstallCommand.php @@ -42,7 +42,7 @@ class InstallCommand extends Command */ private $filesystem; /** - * @var \Shlinkio\Shlink\Installer\Config\ConfigCustomizerManagerInterface + * @var ConfigCustomizerManagerInterface */ private $configCustomizers; /** From a81fd497d41833cc9f276b872d2bdd0ea0ef4dd1 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 29 Sep 2018 10:09:12 +0200 Subject: [PATCH 6/7] Updated Rest translations --- module/Rest/lang/es.mo | Bin 3192 -> 3049 bytes module/Rest/lang/es.po | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/module/Rest/lang/es.mo b/module/Rest/lang/es.mo index 5c1a1db85e453930f41c9653edbbab26355f550d..bd1f572331456c7c7c606abec23bc2657fc9ef8b 100644 GIT binary patch delta 572 zcmX}n&r1|x9LMqRxURnv5jvC*^-Yj0)>2V4!-LXx3!ywj*5TQiXLVqCW|(I-_2i{{ z(bA+t%%&l8C=9?cpu;31b#W&|AkYmwO?cvA7Huv64&uPZs7@*eO9Y-Am0i1 zRgtR{o(>X%``E+}XmD&uWEoSuhljX=-*5?aSY!>KU>WcZr}6Ju{n|*cufaO?S9k?K zkMO&Xc==7iVf}*00v;jvl2K+k#+dYyYR3dOu3s!mjPV}bCpQ&-t2+idhrz~XeJ{0P zZX->c)ugHUj@4$;Y9+g|+g8(N?eaJ@d7L=iu_m&auW6&5t1D0J+RSR2B`@O0Mm61< zobr>;JO6^W#YE*(-_ZPBots^mT`qoB{{+p)R;^EMW*SD@&S+${WxV=$yB(8ay@sY? sLq7239^t+0Fg`9^O*xs6s=k|;CRxaxjth0%ly>LoUk8g~WB6v}KM-7Vp8x;= delta 698 zcmZY4zfTlF6bJBk2L~rVO)T^hLY^cSek7g}AzmO9D3(M+1(9ahd3YPn*>iUH%w6Gy zf{uc?`~#H6DABXj3MyhrXtC1Rnb1)3-CYO;Q_N@g&CL7p@9z1%ovD^XMCTczhj2AZ zv<s6~HJ z{1XDhIQY;_^ZegiSaL%eRPTU;v-MeK-&Q!nnYA578Lhf^qx{jPw47 z&*5+{(Gb+V7<&mHn+OaG@D;+JCAJ^O|g8+n&p5fiwM3S7^y zmA9ez0V|`~7i?GWF4N$O)WtTEw^x@D3@ZJ?BSn9NE26a6_V4VkY<_Z@C(ARB9=E^e z&N9(J{#z?;MoU~bE$g@kZNna;s$h$IKiEU_UWu0kQ#2Ka2EB$-S6mZxnmo9fqQQcv rpA}2>dghvE9n7UP3K(`qmA;t@2UW$6S`$aCN~VZbx`*0_`C`WfK0%{i diff --git a/module/Rest/lang/es.po b/module/Rest/lang/es.po index 61f49207..7998abc0 100644 --- a/module/Rest/lang/es.po +++ b/module/Rest/lang/es.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Shlink 1.0\n" -"POT-Creation-Date: 2018-09-15 18:02+0200\n" -"PO-Revision-Date: 2018-09-15 18:03+0200\n" +"POT-Creation-Date: 2018-09-29 10:08+0200\n" +"PO-Revision-Date: 2018-09-29 10:08+0200\n" "Last-Translator: Alejandro Celaya \n" "Language-Team: \n" "Language: es_ES\n" @@ -89,11 +89,22 @@ msgstr "" "El tipo de autorización proporcionado %s no está soportado. En vez de eso " "utiliza Bearer." -#, php-format +#, fuzzy, php-format +#| msgid "" +#| "Missing or invalid auth token provided. Perform a new authentication " +#| "request and send provided token on every new request on the \"%s\" header" msgid "" "Missing or invalid auth token provided. Perform a new authentication request " -"and send provided token on every new request on the \"%s\" header" +"and send provided token on every new request on the %s header" msgstr "" "No se ha proporcionado token de autenticación o este es inválido. Realiza " "una nueva petición de autenticación y envía el token proporcionado en cada " "nueva petición en la cabecera \"%s\"" + +#, php-format +msgid "" +"Expected one of the following authentication headers, but none were " +"provided, [\"%s\"]" +msgstr "" +"Se esperaba una de las siguientes cabeceras de autenticación, pero no se " +"proporcionó ninguna, [\"%s\"]" From 2edb48e314840076e034f3f98383cf8d7d722c65 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 29 Sep 2018 10:15:39 +0200 Subject: [PATCH 7/7] Documented where the installer command has to be run --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 262f271d..e605d8b0 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Despite how you built the project, you are going to need to install it now, by f * If you are going to use MySQL or PostgreSQL, create an empty database with the name of your choice. * Recursively grant write permissions to the `data` directory. Shlink uses it to cache some information. -* Setup the application by running the `bin/install` script. It will guide you through the installation process. +* Setup the application by running the `bin/install` script. It is a command line tool that will guide you through the installation process. **Take into account that this tool has to be run directly on the server where you plan to host Shlink. Do not run it before uploading/moving it there.** * Configure the web server of your choice to serve shlink using your short domain. For example, assuming your domain is doma.in and shlink is in the `/path/to/shlink` folder, this would be the basic configuration for Nginx and Apache.