-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from shlinkio/develop
Release 8.4
- Loading branch information
Showing
87 changed files
with
868 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ build | |
composer.lock | ||
vendor/ | ||
docker-compose.override.yml | ||
.phpunit.result.cache | ||
config/*.local.php | ||
data | ||
bin/rr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM composer:2 | ||
|
||
RUN apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} && \ | ||
pecl install pcov && \ | ||
docker-php-ext-enable pcov && \ | ||
apk del .phpize-deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
<?xml version="1.0"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="./vendor/autoload.php" | ||
colors="true" | ||
cacheDirectory="build/.phpunit.cache" | ||
> | ||
<testsuites> | ||
<testsuite name="Installer"> | ||
<directory>./test</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
</whitelist> | ||
</filter> | ||
<source> | ||
<include> | ||
<directory>./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Installer\Command; | ||
|
||
use Shlinkio\Shlink\Installer\Command\Model\InitOption; | ||
use Shlinkio\Shlink\Installer\Model\FlagOption; | ||
use Shlinkio\Shlink\Installer\Model\ShlinkInitConfig; | ||
use Shlinkio\Shlink\Installer\Service\InstallationCommandsRunnerInterface; | ||
use Shlinkio\Shlink\Installer\Util\InstallationCommand; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
||
use function Functional\every; | ||
|
||
class InitCommand extends Command | ||
{ | ||
public const NAME = 'init'; | ||
|
||
private readonly FlagOption $skipInitDb; | ||
private readonly FlagOption $clearDbCache; | ||
private readonly FlagOption $initialApiKey; | ||
private readonly FlagOption $updateRoadRunnerBin; | ||
private readonly FlagOption $skipDownloadGeoLiteDb; | ||
|
||
public function __construct(private readonly InstallationCommandsRunnerInterface $commandsRunner) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->skipInitDb = InitOption::SKIP_INITIALIZE_DB->toFlagOption($this); | ||
$this->clearDbCache = InitOption::CLEAR_DB_CACHE->toFlagOption($this); | ||
$this->initialApiKey = InitOption::INITIAL_API_KEY->toFlagOption($this); | ||
$this->updateRoadRunnerBin = InitOption::DOWNLOAD_RR_BINARY->toFlagOption($this); | ||
$this->skipDownloadGeoLiteDb = InitOption::SKIP_DOWNLOAD_GEOLITE->toFlagOption($this); | ||
} | ||
|
||
protected function configure(): void | ||
{ | ||
$this | ||
->setName(self::NAME) | ||
->setDescription( | ||
'Initializes external dependencies required for Shlink to properly work, like DB, cache warmup, ' | ||
. 'initial GeoLite DB download, etc', | ||
); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): ?int | ||
{ | ||
$config = new ShlinkInitConfig( | ||
initializeDb: ! $this->skipInitDb->get($input), | ||
clearDbCache: $this->clearDbCache->get($input), | ||
updateRoadrunnerBinary: $this->updateRoadRunnerBin->get($input), | ||
generateApiKey: $this->initialApiKey->get($input), | ||
downloadGeoLiteDb: ! $this->skipDownloadGeoLiteDb->get($input), | ||
); | ||
$commands = InstallationCommand::resolveCommandsForConfig($config); | ||
$io = new SymfonyStyle($input, $output); | ||
|
||
return every( | ||
$commands, | ||
fn (InstallationCommand $command) => $this->commandsRunner->execPhpCommand($command->value, $io), | ||
) ? 0 : -1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Shlinkio\Shlink\Installer\Command\Model; | ||
|
||
use Shlinkio\Shlink\Installer\Model\FlagOption; | ||
use Symfony\Component\Console\Command\Command; | ||
|
||
enum InitOption: string | ||
{ | ||
case SKIP_INITIALIZE_DB = 'skip-initialize-db'; | ||
case CLEAR_DB_CACHE = 'clear-db-cache'; | ||
case INITIAL_API_KEY = 'initial-api-key'; | ||
case DOWNLOAD_RR_BINARY = 'download-rr-binary'; | ||
case SKIP_DOWNLOAD_GEOLITE = 'skip-download-geolite'; | ||
|
||
public function asCliFlag(): string | ||
{ | ||
return '--' . $this->value; | ||
} | ||
|
||
public function toFlagOption(Command $command): FlagOption | ||
{ | ||
$description = match ($this) { | ||
self:: SKIP_INITIALIZE_DB => | ||
'Skip the initial empty database creation. It will make this command fail on a later stage if the ' | ||
. 'database was not created manually.', | ||
self:: CLEAR_DB_CACHE => 'Clear the database metadata cache.', | ||
self:: INITIAL_API_KEY => 'Create and print initial admin API key.', | ||
self:: DOWNLOAD_RR_BINARY => | ||
'Download a RoadRunner binary. Useful only if you plan to serve Shlink with Roadrunner.', | ||
self:: SKIP_DOWNLOAD_GEOLITE => | ||
'Skip downloading the initial GeoLite DB file. Shlink will try to download it the first time it needs ' | ||
. 'to geolocate visits.', | ||
}; | ||
return new FlagOption($command, $this->value, $description); | ||
} | ||
} |
Oops, something went wrong.