Skip to content

Commit

Permalink
Merge pull request #231 from shlinkio/develop
Browse files Browse the repository at this point in the history
Release 9.3.0
  • Loading branch information
acelaya authored Nov 24, 2024
2 parents 269ea3f + f016ad3 commit f863285
Show file tree
Hide file tree
Showing 47 changed files with 184 additions and 81 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ test-resources export-ignore
.gitignore export-ignore
.phpstorm.meta.php export-ignore
CHANGELOG.md export-ignore
docker-compose.override.yml.dist export-ignore
docker-compose.yml export-ignore
Dockerfile export-ignore
indocker export-ignore
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ on:
jobs:
ci:
uses: shlinkio/github-actions/.github/workflows/php-lib-ci.yml@main
with:
coverage-driver: 'xdebug'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build
composer.lock
vendor/
docker-compose.override.yml
config/*.local.php
data
bin/rr
test-resources/config/params/generated-in-test.php
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ 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).

## [9.3.0] - 2024-11-24
### Added
* *Nothing*

### Changed
* Switch to xdebug for code coverage reports, as pcov is not marking functions as covered
* Update shlinkio coding standard to v2.4
* Update to PHPStan 2.0

### Deprecated
* *Nothing*

### Removed
* Remove dependency on `laminas/laminas-config`.

### Fixed
* *Nothing*


## [9.2.0] - 2024-08-11
### Added
* Add `ROBOTS_ALLOW_ALL_SHORT_URLS` config option.
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM composer:2

RUN apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} && \
pecl install pcov && \
docker-php-ext-enable pcov && \
RUN apk add --update linux-headers && \
apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} && \
pecl install xdebug && \
docker-php-ext-enable xdebug && \
apk del .phpize-deps
20 changes: 13 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
],
"require": {
"php": "^8.2",
"laminas/laminas-config": "^3.9",
"laminas/laminas-config-aggregator": "^1.15",
"laminas/laminas-servicemanager": "^4.2 || ^3.22",
"laminas/laminas-stdlib": "^3.19",
"shlinkio/shlink-config": "^3.1",
"symfony/console": "^7.1",
"symfony/filesystem": "^7.1",
"symfony/process": "^7.1"
"symfony/process": "^7.1",
"webimpress/safe-writer": "^2.2"
},
"require-dev": {
"devster/ubench": "^2.1",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^11.3",
"roave/security-advisories": "dev-master",
"shlinkio/php-coding-standard": "~2.3.0",
"shlinkio/php-coding-standard": "~2.4.0",
"symfony/var-dumper": "^7.1"
},
"autoload": {
Expand All @@ -51,8 +51,14 @@
"cs:fix": "phpcbf",
"stan": "phpstan analyse",
"test": "phpunit --order-by=random --testdox --testdox-summary",
"test:ci": "@test --coverage-clover=build/clover.xml",
"test:pretty": "@test --coverage-html=build/coverage-html"
"test:ci": [
"@putenv XDEBUG_MODE=coverage",
"@test --coverage-clover=build/clover.xml"
],
"test:pretty": [
"@putenv XDEBUG_MODE=coverage",
"@test --coverage-html=build/coverage-html"
]
},
"scripts-descriptions": {
"ci": "<fg=blue;options=bold>Alias for \"cs\", \"stan\" and \"test:ci\"</>",
Expand Down
10 changes: 5 additions & 5 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Shlinkio\Shlink\Installer;

use Laminas\Config\Writer\PhpArray as PhpArrayConfigWriter;
use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Shlinkio\Shlink\Installer\Util\ConfigWriter;
use Shlinkio\Shlink\Installer\Util\InstallationCommand;
use Symfony\Component\Console;
use Symfony\Component\Filesystem\Filesystem;
Expand All @@ -19,7 +19,7 @@
Console\Application::class => Factory\ApplicationFactory::class,
Filesystem::class => InvokableFactory::class,
PhpExecutableFinder::class => InvokableFactory::class,
PhpArrayConfigWriter::class => InvokableFactory::class,
ConfigWriter::class => InvokableFactory::class,
Console\Helper\ProcessHelper::class => Factory\ProcessHelperFactory::class,

Service\InstallationCommandsRunner::class => ConfigAbstractFactory::class,
Expand Down Expand Up @@ -209,17 +209,17 @@
],

Command\InstallCommand::class => [
PhpArrayConfigWriter::class,
ConfigWriter::class,
Service\ShlinkAssetsHandler::class,
Config\ConfigGenerator::class,
],
Command\UpdateCommand::class => [
PhpArrayConfigWriter::class,
ConfigWriter::class,
Service\ShlinkAssetsHandler::class,
Config\ConfigGenerator::class,
],
Command\SetOptionCommand::class => [
PhpArrayConfigWriter::class,
ConfigWriter::class,
Service\ShlinkAssetsHandler::class,
Config\ConfigOptionsManager::class,
Filesystem::class,
Expand Down
6 changes: 0 additions & 6 deletions docker-compose.override.yml.dist

This file was deleted.

1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
services:
shlink_installer_php:
container_name: shlink_installer_php
user: 1000:1000
build:
context: .
volumes:
Expand Down
6 changes: 3 additions & 3 deletions src/Command/AbstractInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace Shlinkio\Shlink\Installer\Command;

use Laminas\Config\Writer\WriterInterface;
use Shlinkio\Shlink\Installer\Command\Model\InitOption;
use Shlinkio\Shlink\Installer\Config\ConfigGeneratorInterface;
use Shlinkio\Shlink\Installer\Model\ImportedConfig;
use Shlinkio\Shlink\Installer\Service\ShlinkAssetsHandler;
use Shlinkio\Shlink\Installer\Service\ShlinkAssetsHandlerInterface;
use Shlinkio\Shlink\Installer\Util\ConfigWriterInterface;
use Shlinkio\Shlink\Installer\Util\Utils;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
Expand All @@ -20,7 +20,7 @@
abstract class AbstractInstallCommand extends Command
{
public function __construct(
private readonly WriterInterface $configWriter,
private readonly ConfigWriterInterface $configWriter,
private readonly ShlinkAssetsHandlerInterface $assetsHandler,
private readonly ConfigGeneratorInterface $configGenerator,
) {
Expand All @@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$normalizedConfig = Utils::normalizeAndKeepEnvVarKeys($config);

// Generate config params files
$this->configWriter->toFile(ShlinkAssetsHandler::GENERATED_CONFIG_PATH, $normalizedConfig, false);
$this->configWriter->toFile(ShlinkAssetsHandler::GENERATED_CONFIG_PATH, $normalizedConfig);
$io->text('<info>Custom configuration properly generated!</info>');
$io->newLine();

Expand Down
8 changes: 4 additions & 4 deletions src/Command/SetOptionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
namespace Shlinkio\Shlink\Installer\Command;

use Generator;
use Laminas\Config\Writer\WriterInterface;
use Shlinkio\Shlink\Installer\Config\ConfigOptionsManagerInterface;
use Shlinkio\Shlink\Installer\Config\Option\ConfigOptionInterface;
use Shlinkio\Shlink\Installer\Exception\InvalidShlinkPathException;
use Shlinkio\Shlink\Installer\Service\ShlinkAssetsHandler;
use Shlinkio\Shlink\Installer\Service\ShlinkAssetsHandlerInterface;
use Shlinkio\Shlink\Installer\Util\ArrayUtils;
use Shlinkio\Shlink\Installer\Util\ConfigWriterInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -33,12 +33,12 @@ class SetOptionCommand extends Command
private string $generatedConfigPath;

public function __construct(
private WriterInterface $configWriter,
private ConfigWriterInterface $configWriter,
private ShlinkAssetsHandlerInterface $assetsHandler,
private ConfigOptionsManagerInterface $optionsManager,
private Filesystem $filesystem,
array $groups,
?array $enabledOptions,
array|null $enabledOptions,
) {
parent::__construct();
$this->groups = array_filter(
Expand Down Expand Up @@ -85,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$plugin = $this->optionsManager->get($this->groups[$optionTitle]);
$answers = include $this->generatedConfigPath;
$answers[$plugin->getEnvVar()] = $plugin->ask($io, $answers);
$this->configWriter->toFile($this->generatedConfigPath, $answers, false);
$this->configWriter->toFile($this->generatedConfigPath, $answers);
$this->assetsHandler->dropCachedConfigIfAny($io);

$io->success('Configuration properly updated');
Expand Down
2 changes: 1 addition & 1 deletion src/Config/ConfigGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ConfigGenerator implements ConfigGeneratorInterface
public function __construct(
private readonly ConfigOptionsManagerInterface $configOptionsManager,
private readonly array $configOptionsGroups,
private readonly ?array $enabledOptions,
private readonly array|null $enabledOptions,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getEnvVar(): string
return 'DB_UNIX_SOCKET';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask('Unix socket (leave empty to not use a socket)');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function getEnvVar(): string
return 'MERCURE_INTERNAL_HUB_URL';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask('Internal URL of the mercure hub server (leave empty to use the public one)');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/QrCode/DefaultBgColorConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getEnvVar(): string
return 'DEFAULT_QR_CODE_BG_COLOR';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'What\'s the default background color for generated QR codes',
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/QrCode/DefaultColorConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getEnvVar(): string
return 'DEFAULT_QR_CODE_COLOR';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'What\'s the default foreground color for generated QR codes',
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/QrCode/DefaultLogoUrlConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getEnvVar(): string
return 'DEFAULT_QR_CODE_LOGO_URL';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'Provide a URL for a logo to be placed inside the QR code (leave empty to use no logo)',
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/Redirect/BaseUrlRedirectConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getEnvVar(): string
return 'DEFAULT_BASE_URL_REDIRECT';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'Custom URL to redirect to when a user hits Shlink\'s base URL (If no value is provided, the '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getEnvVar(): string
return 'DEFAULT_INVALID_SHORT_URL_REDIRECT';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'Custom URL to redirect to when a user hits an invalid short URL (If no value is provided, the '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getEnvVar(): string
return 'DEFAULT_REGULAR_404_REDIRECT';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'Custom URL to redirect to when a user hits a not found URL other than an invalid short URL '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function shouldBeAsked(array $currentOptions): bool
return $isRedisEnabled !== null && parent::shouldBeAsked($currentOptions);
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask('Provide the name of the sentinel service (leave empty if not using redis sentinel)');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/Redis/RedisServersConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function getEnvVar(): string
return self::ENV_VAR;
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
$useRedis = $io->confirm(
'Do you want to use a redis instance, redis cluster or redis sentinels as a shared cache for Shlink? '
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/Robots/RobotsUserAgentsConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getEnvVar(): string
return 'ROBOTS_USER_AGENTS';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'Provide a comma-separated list of user agents for your robots.txt file. Defaults to all user agents (*)',
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/TimezoneConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function getEnvVar(): string
return 'TIMEZONE';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'Set the timezone in which your Shlink instance is running (leave empty to use the one set in PHP config)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function getEnvVar(): string
return 'DISABLE_TRACK_PARAM';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'Provide a parameter name that you will be able to use to disable tracking on specific request to '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function getEnvVar(): string
return 'DISABLE_TRACKING_FROM';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'Provide a comma-separated list of IP addresses, CIDR blocks or wildcard addresses (1.2.*.*) from '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getEnvVar(): string
return 'GEOLITE_LICENSE_KEY';
}

public function ask(StyleInterface $io, array $currentOptions): ?string
public function ask(StyleInterface $io, array $currentOptions): string|null
{
return $io->ask(
'Provide a GeoLite2 license key. Leave empty to disable geolocation. '
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Option/Visit/VisitsThresholdConfigOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function getEnvVar(): string
return 'DELETE_SHORT_URL_THRESHOLD';
}

public function ask(StyleInterface $io, array $currentOptions): ?int
public function ask(StyleInterface $io, array $currentOptions): int|null
{
$result = $io->ask(
'What is the amount of visits from which the system will not allow short URLs to be deleted? Leave empty '
Expand Down
Loading

0 comments on commit f863285

Please sign in to comment.