diff --git a/composer.json b/composer.json index 408e868..f547ba1 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,8 @@ "laminas/laminas-diactoros": "^2.3", "symfony/monolog-bundle": "^3.8", "symfony/dependency-injection": "^5.4", - "symfony/event-dispatcher": "^5.4" + "symfony/event-dispatcher": "^5.4", + "symfony/proxy-manager-bridge": "^6.0" }, "require-dev": { "mikey179/vfsstream": "^1.6", diff --git a/composer.lock b/composer.lock index f36ba52..573ccc4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f20950df8c430dfb63eb743b8b0c494e", + "content-hash": "872d2782048bbbf3742375492e6fa243", "packages": [ { "name": "composer/ca-bundle", @@ -944,6 +944,88 @@ ], "time": "2022-02-28T11:07:21+00:00" }, + { + "name": "friendsofphp/proxy-manager-lts", + "version": "v1.0.13", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/proxy-manager-lts.git", + "reference": "88354616f4cf4f6620910fd035e282173ba453e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/proxy-manager-lts/zipball/88354616f4cf4f6620910fd035e282173ba453e8", + "reference": "88354616f4cf4f6620910fd035e282173ba453e8", + "shasum": "" + }, + "require": { + "laminas/laminas-code": "~3.4.1|^4.0", + "php": ">=7.1", + "symfony/filesystem": "^4.4.17|^5.0|^6.0" + }, + "conflict": { + "laminas/laminas-stdlib": "<3.2.1", + "zendframework/zend-stdlib": "<3.2.1" + }, + "replace": { + "ocramius/proxy-manager": "^2.1" + }, + "require-dev": { + "ext-phar": "*", + "symfony/phpunit-bridge": "^5.4|^6.0" + }, + "type": "library", + "extra": { + "thanks": { + "name": "ocramius/proxy-manager", + "url": "https://github.com/Ocramius/ProxyManager" + } + }, + "autoload": { + "psr-4": { + "ProxyManager\\": "src/ProxyManager" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + } + ], + "description": "Adding support for a wider range of PHP versions to ocramius/proxy-manager", + "homepage": "https://github.com/FriendsOfPHP/proxy-manager-lts", + "keywords": [ + "aop", + "lazy loading", + "proxy", + "proxy pattern", + "service proxies" + ], + "support": { + "issues": "https://github.com/FriendsOfPHP/proxy-manager-lts/issues", + "source": "https://github.com/FriendsOfPHP/proxy-manager-lts/tree/v1.0.13" + }, + "funding": [ + { + "url": "https://github.com/Ocramius", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/ocramius/proxy-manager", + "type": "tidelift" + } + ], + "time": "2022-10-17T19:48:16+00:00" + }, { "name": "incenteev/composer-parameter-handler", "version": "v2.1.5", @@ -1069,6 +1151,72 @@ }, "time": "2022-04-13T08:02:27+00:00" }, + { + "name": "laminas/laminas-code", + "version": "4.7.1", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-code.git", + "reference": "91aabc066d5620428120800c0eafc0411e441a62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-code/zipball/91aabc066d5620428120800c0eafc0411e441a62", + "reference": "91aabc066d5620428120800c0eafc0411e441a62", + "shasum": "" + }, + "require": { + "php": ">=7.4, <8.2" + }, + "require-dev": { + "doctrine/annotations": "^1.13.2", + "ext-phar": "*", + "laminas/laminas-coding-standard": "^2.3.0", + "laminas/laminas-stdlib": "^3.6.1", + "phpunit/phpunit": "^9.5.10", + "psalm/plugin-phpunit": "^0.17.0", + "vimeo/psalm": "^4.13.1" + }, + "suggest": { + "doctrine/annotations": "Doctrine\\Common\\Annotations >=1.0 for annotation features", + "laminas/laminas-stdlib": "Laminas\\Stdlib component" + }, + "type": "library", + "autoload": { + "files": [ + "polyfill/ReflectionEnumPolyfill.php" + ], + "psr-4": { + "Laminas\\Code\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Extensions to the PHP Reflection API, static code scanning, and code generation", + "homepage": "https://laminas.dev", + "keywords": [ + "code", + "laminas", + "laminasframework" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-code/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-code/issues", + "rss": "https://github.com/laminas/laminas-code/releases.atom", + "source": "https://github.com/laminas/laminas-code" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2022-11-21T01:32:31+00:00" + }, { "name": "laminas/laminas-diactoros", "version": "2.22.0", @@ -5213,6 +5361,72 @@ ], "time": "2022-11-19T17:41:50+00:00" }, + { + "name": "symfony/proxy-manager-bridge", + "version": "v6.0.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/proxy-manager-bridge.git", + "reference": "aa68a86bc7df5ee9ff39107f122ebf1931d98ff8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/proxy-manager-bridge/zipball/aa68a86bc7df5ee9ff39107f122ebf1931d98ff8", + "reference": "aa68a86bc7df5ee9ff39107f122ebf1931d98ff8", + "shasum": "" + }, + "require": { + "friendsofphp/proxy-manager-lts": "^1.0.2", + "php": ">=8.0.2", + "symfony/dependency-injection": "^5.4|^6.0" + }, + "require-dev": { + "symfony/config": "^5.4|^6.0" + }, + "type": "symfony-bridge", + "autoload": { + "psr-4": { + "Symfony\\Bridge\\ProxyManager\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides integration for ProxyManager with various Symfony components", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/proxy-manager-bridge/tree/v6.0.6" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-03-02T12:58:14+00:00" + }, { "name": "symfony/psr-http-message-bridge", "version": "v2.1.4", @@ -7838,16 +8052,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.26", + "version": "9.5.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2" + "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/851867efcbb6a1b992ec515c71cdcf20d895e9d2", - "reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a2bc7ffdca99f92d959b3f2270529334030bba38", + "reference": "a2bc7ffdca99f92d959b3f2270529334030bba38", "shasum": "" }, "require": { @@ -7920,7 +8134,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.26" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.27" }, "funding": [ { @@ -7936,7 +8150,7 @@ "type": "tidelift" } ], - "time": "2022-10-28T06:00:21+00:00" + "time": "2022-12-09T07:31:23+00:00" }, { "name": "sebastian/cli-parser", diff --git a/src/Playbloom/Satisfy/Form/Type/AbandonedType.php b/src/Playbloom/Satisfy/Form/Type/AbandonedType.php new file mode 100644 index 0000000..34a3f48 --- /dev/null +++ b/src/Playbloom/Satisfy/Form/Type/AbandonedType.php @@ -0,0 +1,52 @@ +add( + 'package', + TextType::class, + [ + 'required' => true, + 'empty_data' => '', + 'constraints' => [ + new Assert\NotBlank(), + ], + 'attr' => [ + 'placeholder' => 'Abandoned package name', + ], + ] + ) + ->add('replacement', TextType::class, [ + 'required' => true, + 'empty_data' => '', + 'attr' => [ + 'placeholder' => 'Package name/URL pointing to a recommended alternative(can be empty)', + ], + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Abandoned::class, + 'empty_data' => new Abandoned('', null), + ]); + } + + public function getBlockPrefix() + { + return 'AbandonedType'; + } +} diff --git a/src/Playbloom/Satisfy/Form/Type/ConfigurationType.php b/src/Playbloom/Satisfy/Form/Type/ConfigurationType.php index 4f558c4..8c39127 100644 --- a/src/Playbloom/Satisfy/Form/Type/ConfigurationType.php +++ b/src/Playbloom/Satisfy/Form/Type/ConfigurationType.php @@ -3,6 +3,7 @@ namespace Playbloom\Satisfy\Form\Type; use Playbloom\Satisfy\Form\DataTransformer\JsonTextTransformer; +use Playbloom\Satisfy\Model\Abandoned; use Playbloom\Satisfy\Model\Configuration; use Playbloom\Satisfy\Model\PackageStability; use Symfony\Component\Form\AbstractType; @@ -57,6 +58,38 @@ public function buildForm(FormBuilderInterface $builder, array $options) new Assert\Valid(), ], ]) + ->add('blacklist', CollectionType::class, [ + 'required' => false, + 'allow_add' => true, + 'allow_delete' => true, + 'delete_empty' => true, + 'entry_type' => PackageConstraintType::class, + 'prototype' => true, + 'attr' => [ + 'class' => 'collection_require', + 'rel' => 'tooltip', + 'data-title' => 'Package name (keys) and version constraints (values) to exclude after selecting packages', + ], + 'constraints' => [ + new Assert\Valid(), + ], + ]) + ->add('abandoned', CollectionType::class, [ + 'required' => false, + 'allow_add' => true, + 'allow_delete' => true, + 'delete_empty' => true, + 'entry_type' => AbandonedType::class, + 'prototype' => true, + 'attr' => [ + 'class' => 'collection_require', + 'rel' => 'tooltip', + 'data-title' => 'List of packages marked as abandoned for this repository', + ], + 'constraints' => [ + new Assert\Valid(), + ], + ]) ->add('requireAll', Type\CheckboxType::class, [ 'required' => false, 'attr' => [ diff --git a/src/Playbloom/Satisfy/Model/Abandoned.php b/src/Playbloom/Satisfy/Model/Abandoned.php new file mode 100644 index 0000000..6d71125 --- /dev/null +++ b/src/Playbloom/Satisfy/Model/Abandoned.php @@ -0,0 +1,36 @@ +package = $package; + $this->replacement = $replacement; + } + + public function getPackage(): string + { + return $this->package; + } + + public function setPackage(string $package): void + { + $this->package = $package; + } + + public function getReplacement(): ?string + { + return $this->replacement; + } + + public function setReplacement(?string $replacement): void + { + $this->replacement = $replacement; + } +} diff --git a/src/Playbloom/Satisfy/Model/Archive.php b/src/Playbloom/Satisfy/Model/Archive.php index 982a1a1..a47e869 100644 --- a/src/Playbloom/Satisfy/Model/Archive.php +++ b/src/Playbloom/Satisfy/Model/Archive.php @@ -57,6 +57,18 @@ class Archive */ private $checksum = true; + /** + * @SerializedName("ignore-filters") + */ + private bool $ignoreFilters = false; + + /** + * @SerializedName("override-dist-type") + */ + private bool $overrideDistType = false; + + private bool $rearchive = true; + public function getDirectory(): string { return $this->directory; @@ -136,4 +148,34 @@ public function setChecksum(bool $checksum): void { $this->checksum = $checksum; } + + public function isIgnoreFilters(): bool + { + return $this->ignoreFilters; + } + + public function setIgnoreFilters(bool $ignoreFilters): void + { + $this->ignoreFilters = $ignoreFilters; + } + + public function isOverrideDistType(): bool + { + return $this->overrideDistType; + } + + public function setOverrideDistType(bool $overrideDistType): void + { + $this->overrideDistType = $overrideDistType; + } + + public function isRearchive(): bool + { + return $this->rearchive; + } + + public function setRearchive(bool $rearchive): void + { + $this->rearchive = $rearchive; + } } diff --git a/src/Playbloom/Satisfy/Model/Configuration.php b/src/Playbloom/Satisfy/Model/Configuration.php index 14860ef..20304d5 100644 --- a/src/Playbloom/Satisfy/Model/Configuration.php +++ b/src/Playbloom/Satisfy/Model/Configuration.php @@ -2,7 +2,7 @@ namespace Playbloom\Satisfy\Model; -use Symfony\Component\Asset\Package; +use stdClass; use Symfony\Component\Serializer\Annotation\SerializedName; use Webmozart\Assert\Assert; @@ -139,9 +139,14 @@ class Configuration private $twigTemplate; /** - * @var \stdClass + * @var Abandoned[] */ - private $abandoned; + private array $abandoned = []; + + /** + * @var PackageConstraint[] + */ + private array $blacklist = []; /** * @var mixed[]|null @@ -463,16 +468,32 @@ public function setProvidersHistorySize(?int $providersHistorySize): void $this->providersHistorySize = $providersHistorySize; } - public function getAbandoned(): ?\stdClass + /** + * @return Abandoned[]|null + */ + public function getAbandoned(): ?array { return $this->abandoned; } - public function setAbandoned(\stdClass $abandoned): void + /** + * @param Abandoned[]|null $abandoned + */ + public function setAbandoned(?array $abandoned): void { $this->abandoned = $abandoned; } + public function getBlacklist(): ?array + { + return $this->blacklist; + } + + public function setBlacklist(?array $blacklist): void + { + $this->blacklist = $blacklist; + } + public function getComment(): ?string { return $this->comment; diff --git a/src/Playbloom/Satisfy/Persister/ConfigurationNormalizer.php b/src/Playbloom/Satisfy/Persister/ConfigurationNormalizer.php index 8cc804d..67763df 100644 --- a/src/Playbloom/Satisfy/Persister/ConfigurationNormalizer.php +++ b/src/Playbloom/Satisfy/Persister/ConfigurationNormalizer.php @@ -2,6 +2,7 @@ namespace Playbloom\Satisfy\Persister; +use Playbloom\Satisfy\Model\Abandoned; use Playbloom\Satisfy\Model\PackageConstraint; use Playbloom\Satisfy\Model\PackageStability; use Playbloom\Satisfy\Model\Repository; @@ -40,6 +41,10 @@ public function denormalize($data, string $type, string $format = null, array $c return $this->denormalizePackageStability($data); } + if ($type === Abandoned::class . '[]') { + return $this->denormalizeAbandoned($data); + } + if ($this->serializer instanceof DenormalizerInterface) { return $this->serializer->denormalize($data, $type, $format, $context); } @@ -53,6 +58,7 @@ public function supportsDenormalization($data, string $type, string $format = nu case PackageConstraint::class . '[]': case RepositoryInterface::class . '[]': case PackageStability::class . '[]': + case Abandoned::class . '[]': return true; default: } @@ -98,4 +104,17 @@ private function denormalizePackageStability($data): array return $list; } + + private function denormalizeAbandoned($data): array + { + $list = []; + foreach ($data as $package => $replacement) { + if (!is_string($replacement)) { + $replacement = null; + } + $list[] = new Abandoned($package, $replacement); + } + + return $list; + } } diff --git a/src/Playbloom/Satisfy/Persister/JsonPersister.php b/src/Playbloom/Satisfy/Persister/JsonPersister.php index 2b175f5..40a1fdb 100644 --- a/src/Playbloom/Satisfy/Persister/JsonPersister.php +++ b/src/Playbloom/Satisfy/Persister/JsonPersister.php @@ -2,6 +2,7 @@ namespace Playbloom\Satisfy\Persister; +use Playbloom\Satisfy\Model\Abandoned; use Playbloom\Satisfy\Model\Configuration; use Playbloom\Satisfy\Model\PackageConstraint; use Playbloom\Satisfy\Model\PackageStability; @@ -49,6 +50,8 @@ public function flush($object): void AbstractObjectNormalizer::CALLBACKS => [ 'repositories' => [$this, 'normalizeRepositories'], 'require' => [$this, 'normalizeRequire'], + 'blacklist' => [$this, 'normalizeRequire'], + 'abandoned' => [$this, 'normalizeAbandoned'], 'minimumStabilityPerPackage' => [$this, 'normalizePackageStability'], ], JsonEncode::OPTIONS => JSON_PRETTY_PRINT, @@ -83,6 +86,28 @@ public function normalizeRequire($constraints) return $require; } + /** + * @param Abandoned[]|null $abandoned + * + * @return array|null + */ + public function normalizeAbandoned($abandoned) + { + if (empty($abandoned)) { + return null; + } + $list = []; + foreach ($abandoned as $package) { + $replacement = $package->getReplacement(); + if (empty($replacement)) { + $replacement = true; + } + $list[$package->getPackage()] = $replacement; + } + + return $list; + } + /** * @param PackageStability[] $list * diff --git a/src/Playbloom/Satisfy/Resources/config/services.yml b/src/Playbloom/Satisfy/Resources/config/services.yml index 1b44c81..88c0400 100644 --- a/src/Playbloom/Satisfy/Resources/config/services.yml +++ b/src/Playbloom/Satisfy/Resources/config/services.yml @@ -39,6 +39,7 @@ services: Symfony\Component\Lock\LockInterface: '@lock.satis' Playbloom\Satisfy\Model\Configuration: + lazy: true factory: ['@Playbloom\Satisfy\Service\Manager', 'getConfig'] Playbloom\Satisfy\Persister\FilePersister: diff --git a/templates/form/fields.html.twig b/templates/form/fields.html.twig index de2226d..7b7eb9b 100644 --- a/templates/form/fields.html.twig +++ b/templates/form/fields.html.twig @@ -23,3 +23,16 @@
{{ form_widget(form.stability) }} {{ form_errors(form.stability) }}
{% endblock %} + +{% block AbandonedType_row %} +
+ {{ form_errors(form) }} + {{ form_widget(form) }} +
+{% endblock %} + +{% block AbandonedType_widget %} +
{{ form_widget(form.package) }} {{ form_errors(form.package) }}
+
{{ form_widget(form.replacement) }} {{ form_errors(form.replacement) }}
+
+{% endblock %} diff --git a/tests/fixtures/satis-full.json b/tests/fixtures/satis-full.json index d61b6d6..0fe4a0a 100644 --- a/tests/fixtures/satis-full.json +++ b/tests/fixtures/satis-full.json @@ -12,6 +12,13 @@ "require": { "ludofleury\/satisfy":"*" }, + "abandoned": { + "psr/log": true, + "psr/container": "psr/constainer2" + }, + "blacklist": { + "psr/log": "0.x" + }, "require-all": true, "require-dependencies": true, "require-dev-dependencies": false,