Skip to content

Commit

Permalink
Merge pull request #65 from acelaya-forks/feature/shlink-config
Browse files Browse the repository at this point in the history
Feature/shlink config
  • Loading branch information
acelaya authored Mar 13, 2020
2 parents 53e2b95 + c3511b7 commit 3f7adf0
Show file tree
Hide file tree
Showing 63 changed files with 111 additions and 277 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).

## 4.3.0 - 2020-03-13

#### Added

* *Nothing*

#### Changed

* [#64](https://github.com/shlinkio/shlink-installer/issues/64) Added `shlinkio/shlink-config` as a project dependency, deprecating the `Shlinkio\Shlink\Installer\Utils\PathCollection` class.

#### Deprecated

* *Nothing*

#### Removed

* *Nothing*

#### Fixed

* *Nothing*


## 4.2.0 - 2020-02-18

#### Added
Expand Down
6 changes: 2 additions & 4 deletions bin/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

/** @var ServiceLocatorInterface $container */
$container = include __DIR__ . '/../config/container.php';
$runApp = fn (bool $isUpdate) => $container->build(Application::class, ['isUpdate' => $isUpdate])->run();

return [
fn () => $container->build(Application::class, ['isUpdate' => false])->run(),
fn () => $container->build(Application::class, ['isUpdate' => true])->run(),
];
return [fn () => $runApp(false), fn () => $runApp(true)];
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
],
"require": {
"php": "^7.4",
"lstrojny/functional-php": "^1.9",
"laminas/laminas-config": "^3.2",
"laminas/laminas-config-aggregator": "^1.2",
"laminas/laminas-dependency-plugin": "^1.0",
"laminas/laminas-servicemanager": "^3.4",
"laminas/laminas-stdlib": "^3.2",
"lstrojny/functional-php": "^1.9",
"shlinkio/shlink-config": "^1.0",
"symfony/console": "^5.0",
"symfony/filesystem": "^5.0",
"symfony/process": "^5.0"
Expand Down
7 changes: 6 additions & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
PhpExecutableFinder::class => InvokableFactory::class,
Console\Helper\ProcessHelper::class => Factory\ProcessHelperFactory::class,

Service\InstallationCommandsRunner::class => Service\InstallationCommandsRunnerFactory::class,
Service\InstallationCommandsRunner::class => ConfigAbstractFactory::class,
Service\ShlinkAssetsHandler::class => ConfigAbstractFactory::class,
Config\ConfigGenerator::class => Config\ConfigGeneratorFactory::class,
Factory\SwooleInstalledFactory::SWOOLE_INSTALLED => Factory\SwooleInstalledFactory::class,
Expand Down Expand Up @@ -93,6 +93,11 @@
Config\Option\TaskWorkerNumConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Config\Option\WebWorkerNumConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Service\ShlinkAssetsHandler::class => [Filesystem::class],
Service\InstallationCommandsRunner::class => [
Console\Helper\ProcessHelper::class,
PhpExecutableFinder::class,
'config.installer.installation_commands',
],
],

'installer' => [
Expand Down
22 changes: 12 additions & 10 deletions config/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

namespace Shlinkio\Shlink\Installer;

use Laminas\ConfigAggregator\ConfigAggregator;
use Laminas\ConfigAggregator\PhpFileProvider;
use Laminas\ServiceManager\ServiceManager;
use Laminas\Stdlib\ArrayUtils;
use Shlinkio\Shlink\Config;

use function array_reduce;
use function file_exists;

$autoloadFiles = [
Expand All @@ -21,8 +22,7 @@
}
}

$installerConfig = require __DIR__ . '/config.php';
$appConfig = (function () {
$shlinkConfigLoader = static function () {
$appConfigPath = __DIR__ . '/../../../../config/config.php';
if (! file_exists($appConfigPath)) {
return [];
Expand All @@ -33,13 +33,15 @@
unset($appConfig['dependencies']);

return $appConfig;
})();
$localConfig = (function () {
$localConfig = __DIR__ . '/config.local.php';
return file_exists($localConfig) ? require $localConfig : [];
})();
};

$config = (new ConfigAggregator([
Config\ConfigProvider::class,
new PhpFileProvider('config/config.php'), // Installer config
$shlinkConfigLoader, // Overwritten config coming from Shlink
new PhpFileProvider('config/config.local.php'), // Local config
]))->getMergedConfig();

$config = array_reduce([$installerConfig, $appConfig, $localConfig], [ArrayUtils::class, 'merge'], []);
$container = new ServiceManager($config['dependencies']);
$container->setService('config', $config);

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ version: '3'
services:
shlink_installer_php:
container_name: shlink_installer_php
image: composer:1.9.3
image: composer:1.10.0
volumes:
- ./:/app
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>

<exclude>
<file>./src/Util/PathCollection.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>
2 changes: 1 addition & 1 deletion src/Config/ConfigGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Shlinkio\Shlink\Installer\Config;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Config\Option\ConfigOptionInterface;
use Shlinkio\Shlink\Installer\Config\Option\DependentConfigOptionInterface;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

use function array_combine;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/ConfigGeneratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

interface ConfigGeneratorInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/AbstractDriverDependentConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;

abstract class AbstractDriverDependentConfigOption implements
ConfigOptionInterface,
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/AbstractWorkerNumConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Shlinkio\Shlink\Installer\Config\Option;

use Closure;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Config\Util\ConfigOptionsValidatorsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

use function sprintf;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/BaseConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;

abstract class BaseConfigOption implements ConfigOptionInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/BasePathConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class BasePathConfigOption extends BaseConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/BaseUrlRedirectConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Config\Util\ConfigOptionsValidatorsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class BaseUrlRedirectConfigOption extends BaseConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/CheckVisitsThresholdConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class CheckVisitsThresholdConfigOption extends BaseConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/ConfigOptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

interface ConfigOptionInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/DatabaseDriverConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

use function array_keys;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/DatabaseHostConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class DatabaseHostConfigOption extends AbstractNonSqliteDependentConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/DatabaseMySqlOptionsConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class DatabaseMySqlOptionsConfigOption extends AbstractDriverDependentConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/DatabaseNameConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class DatabaseNameConfigOption extends AbstractNonSqliteDependentConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/DatabasePasswordConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Util\AskUtilsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class DatabasePasswordConfigOption extends AbstractNonSqliteDependentConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/DatabasePortConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class DatabasePortConfigOption extends AbstractNonSqliteDependentConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/DatabaseSqlitePathConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class DatabaseSqlitePathConfigOption extends AbstractDriverDependentConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/DatabaseUserConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Util\AskUtilsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class DatabaseUserConfigOption extends AbstractNonSqliteDependentConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/DisableTrackParamConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class DisableTrackParamConfigOption extends BaseConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/InvalidShortUrlRedirectConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Config\Util\ConfigOptionsValidatorsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class InvalidShortUrlRedirectConfigOption extends BaseConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/RedisServersConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Config\Util\ConfigOptionsValidatorsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

use function explode;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/Regular404RedirectConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Config\Util\ConfigOptionsValidatorsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class Regular404RedirectConfigOption extends BaseConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/ShortCodeLengthOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Config\Util\ConfigOptionsValidatorsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class ShortCodeLengthOption extends BaseConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/ShortDomainHostConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Util\AskUtilsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class ShortDomainHostConfigOption extends BaseConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/ShortDomainSchemaConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class ShortDomainSchemaConfigOption extends BaseConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/ValidateUrlConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Installer\Util\PathCollection;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class ValidateUrlConfigOption extends BaseConfigOption
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/VisitsThresholdConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Shlinkio\Shlink\Installer\Config\Option;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Config\Util\ConfigOptionsValidatorsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class VisitsThresholdConfigOption implements ConfigOptionInterface, DependentConfigOptionInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/VisitsWebhooksConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Shlinkio\Shlink\Installer\Config\Option;

use Closure;
use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Config\Util\ConfigOptionsValidatorsTrait;
use Shlinkio\Shlink\Installer\Util\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;

class VisitsWebhooksConfigOption implements ConfigOptionInterface
Expand Down
Loading

0 comments on commit 3f7adf0

Please sign in to comment.