Initial commit
This commit is contained in:
@@ -5,6 +5,12 @@ 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\PackagePublisher;
|
||||
use NoccyLabs\Composer\PackagePlugin\Project\ProjectInfo;
|
||||
use NoccyLabs\Composer\PackagePlugin\Registry\Credentials\InsecureStore;
|
||||
use NoccyLabs\Composer\PackagePlugin\Registry\Gitea\GiteaProvider;
|
||||
use NoccyLabs\Composer\PackagePlugin\Registry\RegistryFactory;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
||||
class PackagePublishCommand extends BaseCommand
|
||||
{
|
||||
@@ -12,12 +18,38 @@ class PackagePublishCommand extends BaseCommand
|
||||
{
|
||||
$this
|
||||
->setName('package:publish')
|
||||
->setDescription("Publish a package to a composer repository");
|
||||
->setDescription("Publish a package to a composer package registry")
|
||||
->addArgument("registry", InputArgument::OPTIONAL, "The registry to publish to")
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$output->writeln('Executing');
|
||||
$credentials = new InsecureStore();
|
||||
|
||||
$providers = [
|
||||
'gitea' => new GiteaProvider($credentials)
|
||||
];
|
||||
|
||||
$registry = new RegistryFactory($providers);
|
||||
$publisher = new PackagePublisher($registry, $output);
|
||||
|
||||
$project = ProjectInfo::read();
|
||||
|
||||
$registry = $input->getArgument("registry");
|
||||
if (!$registry) {
|
||||
$output->writeln([
|
||||
"Missing registry to publish to. Please specify the registry like this:",
|
||||
"",
|
||||
" <info>gitea:<server></> - to publish to <info>server</> as the default user",
|
||||
" <info>gitea:<server>/<owner></> - to publish to <info>server</> as <info>owner</>",
|
||||
""
|
||||
]);
|
||||
return self::INVALID;
|
||||
}
|
||||
|
||||
$publisher->publish($project, $registry);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user