35 lines
1.4 KiB
PHP
35 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace NoccyLabs\Composer\PackagePlugin\Package;
|
||
|
|
|
||
|
|
use NoccyLabs\Composer\PackagePlugin\Project\ProjectInfo;
|
||
|
|
use NoccyLabs\Composer\PackagePlugin\Registry\RegistryFactory;
|
||
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
||
|
|
|
||
|
|
class PackagePublisher
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
public readonly RegistryFactory $registryFactory,
|
||
|
|
public readonly OutputInterface $output,
|
||
|
|
)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
public function publish(ProjectInfo $project, string $registryUri): void
|
||
|
|
{
|
||
|
|
// $this->output->writeln("Resolving registry for <comment>{$registryUri}</>...");
|
||
|
|
$registry = $this->registryFactory->createRegistryFromUri($registryUri);
|
||
|
|
|
||
|
|
$this->output->writeln("Publishing package file <info>{$project->filename}</> to <comment>{$registry->server}</> as <comment>{$registry->owner}</>...");
|
||
|
|
$registry->publishPackageVersion($project);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function unpublish(ProjectInfo $project, string $registryUri): void
|
||
|
|
{
|
||
|
|
// $this->output->writeln("Resolving registry for <comment>{$registryUri}</>...");
|
||
|
|
$registry = $this->registryFactory->createRegistryFromUri($registryUri);
|
||
|
|
|
||
|
|
$this->output->writeln("Unpublishing package <options=bold>{$project->name}</>@<options=bold>{$project->version}</> from <comment>{$registry->server}</> for <comment>{$registry->owner}</>...");
|
||
|
|
$registry->unpublishPackageVersion($project);
|
||
|
|
}
|
||
|
|
}
|