Implement common abstract base command

This commit is contained in:
Christopher Vagnetoft
2026-01-09 17:43:54 +01:00
parent 520de9e7b8
commit c30c04d1f9
5 changed files with 34 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ use NoccyLabs\Composer\PackagePlugin\Registry\RegistryFactory;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
class PackageBuildCommand extends BaseCommand class PackageBuildCommand extends PackageCommand
{ {
protected function configure(): void protected function configure(): void
{ {
@@ -48,7 +48,7 @@ class PackageBuildCommand extends BaseCommand
} }
if ($registry) { if ($registry) {
$credentials = new InsecureStore(); $credentials = $this->getCredentialsStore();
$providers = [ $providers = [
'gitea' => new GiteaProvider($credentials) 'gitea' => new GiteaProvider($credentials)

View File

@@ -0,0 +1,26 @@
<?php
namespace NoccyLabs\Composer\PackagePlugin\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Composer\Command\BaseCommand;
use NoccyLabs\Composer\PackagePlugin\Package\PackageBuilder;
use NoccyLabs\Composer\PackagePlugin\Package\PackagePublisher;
use NoccyLabs\Composer\PackagePlugin\Project\ProjectInfo;
use NoccyLabs\Composer\PackagePlugin\Registry\Credentials\InsecureStore;
use NoccyLabs\Composer\PackagePlugin\Registry\Credentials\StoreInterface;
use NoccyLabs\Composer\PackagePlugin\Registry\Gitea\GiteaProvider;
use NoccyLabs\Composer\PackagePlugin\Registry\RegistryFactory;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
abstract class PackageCommand extends BaseCommand
{
public function getCredentialsStore(): StoreInterface
{
return new InsecureStore();
}
}

View File

@@ -13,7 +13,7 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Console\Style\SymfonyStyle;
class PackageLoginCommand extends BaseCommand class PackageLoginCommand extends PackageCommand
{ {
protected function configure(): void protected function configure(): void
{ {
@@ -27,7 +27,7 @@ class PackageLoginCommand extends BaseCommand
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$credentials = new InsecureStore(); $credentials = $this->getCredentialsStore();
$io = new SymfonyStyle($input, $output); $io = new SymfonyStyle($input, $output);

View File

@@ -13,7 +13,7 @@ use NoccyLabs\Composer\PackagePlugin\Registry\RegistryFactory;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
class PackagePublishCommand extends BaseCommand class PackagePublishCommand extends PackageCommand
{ {
protected function configure(): void protected function configure(): void
{ {
@@ -27,7 +27,7 @@ class PackagePublishCommand extends BaseCommand
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$credentials = new InsecureStore(); $credentials = $this->getCredentialsStore();
$registry = $input->getArgument("registry"); $registry = $input->getArgument("registry");
$version = $input->getArgument("version"); $version = $input->getArgument("version");

View File

@@ -13,7 +13,7 @@ use NoccyLabs\Composer\PackagePlugin\Registry\RegistryFactory;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
class PackageUnpublishCommand extends BaseCommand class PackageUnpublishCommand extends PackageCommand
{ {
protected function configure(): void protected function configure(): void
{ {
@@ -28,7 +28,7 @@ class PackageUnpublishCommand extends BaseCommand
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$credentials = new InsecureStore(); $credentials = $this->getCredentialsStore();
$providers = [ $providers = [
'gitea' => new GiteaProvider($credentials) 'gitea' => new GiteaProvider($credentials)