From a65ce649ac85267301997bb8fb8fd4dd6d156822 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 29 Sep 2018 09:52:32 +0200 Subject: [PATCH] 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 +