Skip to content

Commit

Permalink
Merge pull request #84 from shlinkio/develop
Browse files Browse the repository at this point in the history
Release 5.0.0
  • Loading branch information
acelaya authored May 9, 2020
2 parents 4232239 + 60dac73 commit 14bfcc5
Show file tree
Hide file tree
Showing 72 changed files with 796 additions and 170 deletions.
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,59 @@ 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).

## 5.0.0 - 2020-05-09

#### Added

* [#71](https://github.com/shlinkio/shlink-installer/issues/71) Added config options for mercure integration.
* [#82](https://github.com/shlinkio/shlink-installer/issues/82) Added config option to optionally disable IP address anonymization.
* [#76](https://github.com/shlinkio/shlink-installer/issues/76) Added `MYSQL_ATTR_USE_BUFFERED_QUERY => true` driver option for mysql and mariadb connections.

#### Changed

* [#74](https://github.com/shlinkio/shlink-installer/issues/74) Grouped several config options to sub-namespaces. The changed classes are as follows.

* `Database`:
* `Config\Option\DatabaseDriverConfigOption` -> `Config\Option\Database\DatabaseDriverConfigOption`
* `Config\Option\DatabaseNameConfigOption` -> `Config\Option\Database\DatabaseNameConfigOption`
* `Config\Option\DatabaseHostConfigOption` -> `Config\Option\Database\DatabaseHostConfigOption`
* `Config\Option\DatabasePortConfigOption` -> `Config\Option\Database\DatabasePortConfigOption`
* `Config\Option\DatabaseUserConfigOption` -> `Config\Option\Database\DatabaseUserConfigOption`
* `Config\Option\DatabasePasswordConfigOption` -> `Config\Option\Database\DatabasePasswordConfigOption`
* `Config\Option\DatabaseSqlitePathConfigOption` -> `Config\Option\Database\DatabaseSqlitePathConfigOption`
* `Config\Option\DatabaseMySqlOptionsConfigOption` -> `Config\Option\Database\DatabaseMySqlOptionsConfigOption`
* `UrlShortener`:
* `Config\Option\ShortDomainHostConfigOption` -> `Config\Option\UrlShortener\ShortDomainHostConfigOption`
* `Config\Option\ShortDomainSchemaConfigOption` -> `Config\Option\UrlShortener\ShortDomainSchemaConfigOption`
* `Config\Option\ValidateUrlConfigOption` -> `Config\Option\UrlShortener\ValidateUrlConfigOption`
* `Config\Option\ShortCodeLengthOption` -> `Config\Option\UrlShortener\ShortCodeLengthOption`
* `Visit`:
* `Config\Option\VisitsWebhooksConfigOption` -> `Config\Option\Visit\VisitsWebhooksConfigOption`
* `Config\Option\CheckVisitsThresholdConfigOption` -> `Config\Option\Visit\CheckVisitsThresholdConfigOption`
* `Config\Option\VisitsThresholdConfigOption` -> `Config\Option\Visit\VisitsThresholdConfigOption`
* `Redirect`:
* `Config\Option\BaseUrlRedirectConfigOption` -> `Config\Option\Redirect\BaseUrlRedirectConfigOption`
* `Config\Option\InvalidShortUrlRedirectConfigOption` -> `Config\Option\Redirect\InvalidShortUrlRedirectConfigOption`
* `Config\Option\Regular404RedirectConfigOption` -> `Config\Option\Redirect\Regular404RedirectConfigOption`
* `Worker`:
* `Config\Option\TaskWorkerNumConfigOption` -> `Config\Option\Worker\TaskWorkerNumConfigOption`
* `Config\Option\WebWorkerNumConfigOption` -> `Config\Option\Worker\WebWorkerNumConfigOption`

The rest remain the same.

#### Deprecated

* *Nothing*

#### Removed

* *Nothing*

#### Fixed

* [#78](https://github.com/shlinkio/shlink-installer/issues/78) Allowed clear cache command to fail, and ensured it is not run on new installs.


## 4.4.0 - 2020-04-29

#### Added
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ return [

'installer' => [
'enabled_options' => [
Option\DatabaseDriverConfigOption::class,
Option\DatabaseHostConfigOption::class,
Option\Database\DatabaseDriverConfigOption::class,
Option\Database\DatabaseHostConfigOption::class,
Option\BasePathConfigOption::class,
Option\Regular404RedirectConfigOption::class,
Option\ShortDomainHostConfigOption::class,
Option\ShortDomainSchemaConfigOption::class,
Option\Redirect\Regular404RedirectConfigOption::class,
Option\UrlShortener\ShortDomainHostConfigOption::class,
Option\UrlShortener\ShortDomainSchemaConfigOption::class,
],
],

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
"require-dev": {
"devster/ubench": "^2.0",
"infection/infection": "^0.16.1",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^0.12.18",
"phpunit/phpunit": "~9.0.2",
"phpunit/phpunit": "^9.1",
"roave/security-advisories": "dev-master",
"shlinkio/php-coding-standard": "~2.1.0",
"symfony/var-dumper": "^5.0"
Expand Down
112 changes: 67 additions & 45 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,71 +29,89 @@
'config_options' => [
'groups' => [
'DATABASE' => [
Config\Option\DatabaseDriverConfigOption::class,
Config\Option\DatabaseNameConfigOption::class,
Config\Option\DatabaseHostConfigOption::class,
Config\Option\DatabasePortConfigOption::class,
Config\Option\DatabaseUserConfigOption::class,
Config\Option\DatabasePasswordConfigOption::class,
Config\Option\DatabaseSqlitePathConfigOption::class,
Config\Option\DatabaseMySqlOptionsConfigOption::class,
Config\Option\Database\DatabaseDriverConfigOption::class,
Config\Option\Database\DatabaseNameConfigOption::class,
Config\Option\Database\DatabaseHostConfigOption::class,
Config\Option\Database\DatabasePortConfigOption::class,
Config\Option\Database\DatabaseUserConfigOption::class,
Config\Option\Database\DatabasePasswordConfigOption::class,
Config\Option\Database\DatabaseSqlitePathConfigOption::class,
Config\Option\Database\DatabaseMySqlOptionsConfigOption::class,
],
'URL SHORTENER' => [
Config\Option\ShortDomainHostConfigOption::class,
Config\Option\ShortDomainSchemaConfigOption::class,
Config\Option\ValidateUrlConfigOption::class,
Config\Option\VisitsWebhooksConfigOption::class,
Config\Option\ShortCodeLengthOption::class,
Config\Option\GeoLiteLicenseKeyConfigOption::class,
Config\Option\UrlShortener\ShortDomainHostConfigOption::class,
Config\Option\UrlShortener\ShortDomainSchemaConfigOption::class,
Config\Option\UrlShortener\ValidateUrlConfigOption::class,
Config\Option\UrlShortener\ShortCodeLengthOption::class,
Config\Option\Visit\VisitsWebhooksConfigOption::class,
Config\Option\UrlShortener\GeoLiteLicenseKeyConfigOption::class,
Config\Option\UrlShortener\IpAnonymizationConfigOption::class,
],
'REDIRECTS' => [
Config\Option\BaseUrlRedirectConfigOption::class,
Config\Option\InvalidShortUrlRedirectConfigOption::class,
Config\Option\Regular404RedirectConfigOption::class,
Config\Option\Redirect\BaseUrlRedirectConfigOption::class,
Config\Option\Redirect\InvalidShortUrlRedirectConfigOption::class,
Config\Option\Redirect\Regular404RedirectConfigOption::class,
],
'APPLICATION' => [
Config\Option\DisableTrackParamConfigOption::class,
Config\Option\CheckVisitsThresholdConfigOption::class,
Config\Option\VisitsThresholdConfigOption::class,
Config\Option\Visit\CheckVisitsThresholdConfigOption::class,
Config\Option\Visit\VisitsThresholdConfigOption::class,
Config\Option\BasePathConfigOption::class,
Config\Option\Worker\TaskWorkerNumConfigOption::class,
Config\Option\Worker\WebWorkerNumConfigOption::class,
],
'INTEGRATIONS' => [
Config\Option\RedisServersConfigOption::class,
Config\Option\TaskWorkerNumConfigOption::class,
Config\Option\WebWorkerNumConfigOption::class,
Config\Option\Mercure\EnableMercureConfigOption::class,
Config\Option\Mercure\MercurePublicUrlConfigOption::class,
Config\Option\Mercure\MercureInternalUrlConfigOption::class,
Config\Option\Mercure\MercureJwtSecretConfigOption::class,
],
],

'factories' => [
Config\Option\BasePathConfigOption::class => InvokableFactory::class,
Config\Option\CheckVisitsThresholdConfigOption::class => InvokableFactory::class,
Config\Option\VisitsThresholdConfigOption::class => InvokableFactory::class,
Config\Option\DatabaseDriverConfigOption::class => InvokableFactory::class,
Config\Option\DatabaseNameConfigOption::class => InvokableFactory::class,
Config\Option\DatabaseHostConfigOption::class => InvokableFactory::class,
Config\Option\DatabasePortConfigOption::class => InvokableFactory::class,
Config\Option\DatabaseUserConfigOption::class => InvokableFactory::class,
Config\Option\DatabasePasswordConfigOption::class => InvokableFactory::class,
Config\Option\DatabaseSqlitePathConfigOption::class => InvokableFactory::class,
Config\Option\DatabaseMySqlOptionsConfigOption::class => InvokableFactory::class,
Config\Option\Visit\CheckVisitsThresholdConfigOption::class => InvokableFactory::class,
Config\Option\Visit\VisitsThresholdConfigOption::class => InvokableFactory::class,
Config\Option\Database\DatabaseDriverConfigOption::class => InvokableFactory::class,
Config\Option\Database\DatabaseNameConfigOption::class => InvokableFactory::class,
Config\Option\Database\DatabaseHostConfigOption::class => InvokableFactory::class,
Config\Option\Database\DatabasePortConfigOption::class => InvokableFactory::class,
Config\Option\Database\DatabaseUserConfigOption::class => InvokableFactory::class,
Config\Option\Database\DatabasePasswordConfigOption::class => InvokableFactory::class,
Config\Option\Database\DatabaseSqlitePathConfigOption::class => InvokableFactory::class,
Config\Option\Database\DatabaseMySqlOptionsConfigOption::class => InvokableFactory::class,
Config\Option\DisableTrackParamConfigOption::class => InvokableFactory::class,
Config\Option\BaseUrlRedirectConfigOption::class => InvokableFactory::class,
Config\Option\InvalidShortUrlRedirectConfigOption::class => InvokableFactory::class,
Config\Option\Regular404RedirectConfigOption::class => InvokableFactory::class,
Config\Option\ShortDomainHostConfigOption::class => InvokableFactory::class,
Config\Option\ShortDomainSchemaConfigOption::class => InvokableFactory::class,
Config\Option\ValidateUrlConfigOption::class => InvokableFactory::class,
Config\Option\Redirect\BaseUrlRedirectConfigOption::class => InvokableFactory::class,
Config\Option\Redirect\InvalidShortUrlRedirectConfigOption::class => InvokableFactory::class,
Config\Option\Redirect\Regular404RedirectConfigOption::class => InvokableFactory::class,
Config\Option\UrlShortener\ShortDomainHostConfigOption::class => InvokableFactory::class,
Config\Option\UrlShortener\ShortDomainSchemaConfigOption::class => InvokableFactory::class,
Config\Option\UrlShortener\ValidateUrlConfigOption::class => InvokableFactory::class,
Config\Option\RedisServersConfigOption::class => InvokableFactory::class,
Config\Option\VisitsWebhooksConfigOption::class => ConfigAbstractFactory::class,
Config\Option\TaskWorkerNumConfigOption::class => ConfigAbstractFactory::class,
Config\Option\WebWorkerNumConfigOption::class => ConfigAbstractFactory::class,
Config\Option\ShortCodeLengthOption::class => InvokableFactory::class,
Config\Option\GeoLiteLicenseKeyConfigOption::class => InvokableFactory::class,
Config\Option\Visit\VisitsWebhooksConfigOption::class => ConfigAbstractFactory::class,
Config\Option\Worker\TaskWorkerNumConfigOption::class => ConfigAbstractFactory::class,
Config\Option\Worker\WebWorkerNumConfigOption::class => ConfigAbstractFactory::class,
Config\Option\UrlShortener\ShortCodeLengthOption::class => InvokableFactory::class,
Config\Option\Mercure\EnableMercureConfigOption::class => ConfigAbstractFactory::class,
Config\Option\Mercure\MercurePublicUrlConfigOption::class => ConfigAbstractFactory::class,
Config\Option\Mercure\MercureInternalUrlConfigOption::class => ConfigAbstractFactory::class,
Config\Option\Mercure\MercureJwtSecretConfigOption::class => ConfigAbstractFactory::class,
Config\Option\UrlShortener\GeoLiteLicenseKeyConfigOption::class => InvokableFactory::class,
Config\Option\UrlShortener\IpAnonymizationConfigOption::class => InvokableFactory::class,
],
],

ConfigAbstractFactory::class => [
Config\Option\VisitsWebhooksConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Config\Option\TaskWorkerNumConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Config\Option\WebWorkerNumConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Config\Option\Visit\VisitsWebhooksConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Config\Option\Worker\TaskWorkerNumConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Config\Option\Worker\WebWorkerNumConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Config\Option\Mercure\EnableMercureConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Config\Option\Mercure\MercurePublicUrlConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Config\Option\Mercure\MercureInternalUrlConfigOption::class => [
Factory\SwooleInstalledFactory::SWOOLE_INSTALLED,
],
Config\Option\Mercure\MercureJwtSecretConfigOption::class => [Factory\SwooleInstalledFactory::SWOOLE_INSTALLED],
Service\ShlinkAssetsHandler::class => [Filesystem::class],
Service\InstallationCommandsRunner::class => [
Console\Helper\ProcessHelper::class,
Expand All @@ -108,21 +126,25 @@
'command' => 'vendor/doctrine/orm/bin/doctrine.php orm:schema-tool:create',
'initMessage' => 'Initializing database...',
'errorMessage' => 'Error generating database.',
'failOnError' => true,
],
'db_migrate' => [
'command' => 'vendor/doctrine/migrations/bin/doctrine-migrations.php migrations:migrate',
'initMessage' => 'Updating database...',
'errorMessage' => 'Error updating database.',
'failOnError' => true,
],
'orm_proxies' => [
'command' => 'vendor/doctrine/orm/bin/doctrine.php orm:generate-proxies',
'initMessage' => 'Generating proxies...',
'errorMessage' => 'Error generating proxies.',
'failOnError' => true,
],
'orm_clear_cache' => [
'command' => 'vendor/doctrine/orm/bin/doctrine.php orm:clear-cache:metadata',
'initMessage' => 'Clearing entities cache...',
'errorMessage' => 'Error clearing entities cache.',
'failOnError' => false,
],
],
],
Expand Down
9 changes: 6 additions & 3 deletions src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
use Symfony\Component\Console\Style\SymfonyStyle;

use function Functional\every;
use function Functional\tail;

class InstallCommand extends Command
{
private const POST_INSTALL_COMMANDS = [
public const POST_INSTALL_COMMANDS = [
'db_create_schema',
'db_migrate',
'orm_proxies',
];
public const POST_UPDATE_COMMANDS = [
'db_migrate',
'orm_proxies',
'orm_clear_cache',
];

Expand Down Expand Up @@ -97,7 +100,7 @@ private function resolvePreviousConfig(SymfonyStyle $io): ImportedConfig

private function execPostInstallCommands(SymfonyStyle $io): bool
{
$commands = $this->isUpdate ? tail(self::POST_INSTALL_COMMANDS) : self::POST_INSTALL_COMMANDS;
$commands = $this->isUpdate ? self::POST_UPDATE_COMMANDS : self::POST_INSTALL_COMMANDS;

return every($commands, fn (string $commandName) => $this->commandsRunner->execPhpCommand($commandName, $io));
}
Expand Down
23 changes: 23 additions & 0 deletions src/Config/Option/AbstractSwooleDependentConfigOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Shlinkio\Shlink\Installer\Config\Option;

use Closure;
use Shlinkio\Shlink\Config\Collection\PathCollection;

abstract class AbstractSwooleDependentConfigOption implements ConfigOptionInterface
{
private Closure $swooleInstalled;

public function __construct(callable $swooleInstalled)
{
$this->swooleInstalled = Closure::fromCallable($swooleInstalled);
}

public function shouldBeAsked(PathCollection $currentOptions): bool
{
return ($this->swooleInstalled)() && ! $currentOptions->pathExists($this->getConfigPath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

declare(strict_types=1);

namespace Shlinkio\Shlink\Installer\Config\Option;
namespace Shlinkio\Shlink\Installer\Config\Option\Database;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Config\Option\ConfigOptionInterface;
use Shlinkio\Shlink\Installer\Config\Option\Database\DatabaseDriverConfigOption;
use Shlinkio\Shlink\Installer\Config\Option\DependentConfigOptionInterface;

abstract class AbstractDriverDependentConfigOption implements
ConfigOptionInterface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

declare(strict_types=1);

namespace Shlinkio\Shlink\Installer\Config\Option;
namespace Shlinkio\Shlink\Installer\Config\Option\Database;

use Shlinkio\Shlink\Installer\Config\Option\Database\AbstractDriverDependentConfigOption;
use Shlinkio\Shlink\Installer\Config\Option\Database\DatabaseDriverConfigOption;

abstract class AbstractNonSqliteDependentConfigOption extends AbstractDriverDependentConfigOption
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

declare(strict_types=1);

namespace Shlinkio\Shlink\Installer\Config\Option;
namespace Shlinkio\Shlink\Installer\Config\Option\Database;

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

use function array_keys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Shlinkio\Shlink\Installer\Config\Option;
namespace Shlinkio\Shlink\Installer\Config\Option\Database;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Shlinkio\Shlink\Installer\Config\Option;
namespace Shlinkio\Shlink\Installer\Config\Option\Database;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;
Expand All @@ -19,6 +19,8 @@ public function ask(StyleInterface $io, PathCollection $currentOptions): array
return [
// PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
1002 => 'SET NAMES utf8',
// 1000 -> PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
1000 => true,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Shlinkio\Shlink\Installer\Config\Option;
namespace Shlinkio\Shlink\Installer\Config\Option\Database;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Symfony\Component\Console\Style\StyleInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Shlinkio\Shlink\Installer\Config\Option;
namespace Shlinkio\Shlink\Installer\Config\Option\Database;

use Shlinkio\Shlink\Config\Collection\PathCollection;
use Shlinkio\Shlink\Installer\Util\AskUtilsTrait;
Expand Down
Loading

0 comments on commit 14bfcc5

Please sign in to comment.