Skip to content

Commit

Permalink
[Bard] Various updates (SonsOfPHP#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaEstes authored Oct 1, 2024
1 parent b67565d commit a57e46f
Show file tree
Hide file tree
Showing 16 changed files with 348 additions and 244 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ To get the diff between two versions, go to https://github.com/SonsOfPHP/sonsofp

## [Unreleased]

* [PR #228](https://github.com/SonsOfPHP/sonsofphp/pull/228) [Bard] Various updates
* [PR #227](https://github.com/SonsOfPHP/sonsofphp/pull/227) [Cache] FilesystemAdapter, Marshallers, and other updates
* [PR #226](https://github.com/SonsOfPHP/sonsofphp/pull/226) [Registry] New Component and Contract
* [PR #225](https://github.com/SonsOfPHP/sonsofphp/pull/225) Maintenance
Expand Down
264 changes: 140 additions & 124 deletions composer.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/SonsOfPHP/Bard/dist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.phar
29 changes: 11 additions & 18 deletions src/SonsOfPHP/Bard/src/Console/Command/MergeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
use SonsOfPHP\Bard\Worker\File\Composer\Package\BranchAlias;
use SonsOfPHP\Bard\Worker\File\Composer\Package\Funding;
use SonsOfPHP\Bard\Worker\File\Composer\Package\Support;
use SonsOfPHP\Bard\Worker\File\Composer\Root\ClearSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadDevSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateProvideSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateReplaceSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireDevSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireSection;
use SonsOfPHP\Component\Json\Json;
use Symfony\Component\Console\Helper\HelperInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -31,21 +31,12 @@
*/
final class MergeCommand extends AbstractCommand
{
private readonly Json $json;

private array $bardConfig;
private JsonFile $bardConfig;

private string $mainComposerFile;

private ?HelperInterface $formatter = null;

public function __construct()
{
$this->json = new Json();

parent::__construct();
}

protected function configure(): void
{
$this
Expand All @@ -63,9 +54,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
throw new RuntimeException(sprintf('"%s" file does not exist', $bardConfigFile));
}

$this->bardConfig = $this->json->getDecoder()
->objectAsArray()
->decode(file_get_contents($bardConfigFile));
$this->bardConfig = new JsonFile($bardConfigFile);

$this->mainComposerFile = $input->getOption('working-dir') . '/composer.json';
if (!file_exists($this->mainComposerFile)) {
Expand All @@ -83,10 +72,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$rootComposerJsonFile = new JsonFile($input->getOption('working-dir') . '/composer.json');

// Clean out a few of the sections in root composer.json file
$rootComposerJsonFile = $rootComposerJsonFile->setSection('autoload', []);
$rootComposerJsonFile = $rootComposerJsonFile->setSection('autoload-dev', []);

foreach ($this->bardConfig['packages'] as $pkg) {
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('autoload'));
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('autoload-dev'));
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('require'));
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('require-dev'));
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('replace'));
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('provide'));

foreach ($this->bardConfig->getSection('packages') as $pkg) {
$pkgComposerFile = realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json');
if (!file_exists($pkgComposerFile)) {
$output->writeln(sprintf('No "%s" found, skipping', $packageComposerFile));
Expand Down
5 changes: 4 additions & 1 deletion src/SonsOfPHP/Bard/src/Console/Command/PushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
['git', 'subtree', 'push', '-P', $pkg['path'], $pkg['repository'], $input->getOption('branch')],
];

$io->text(sprintf('Pushing <info>%s</>', $pkgName));
$output->writeln($this->getHelper('formatter')->formatSection($pkgName, 'Pushing...'));

Check failure on line 53 in src/SonsOfPHP/Bard/src/Console/Command/PushCommand.php

View workflow job for this annotation

GitHub Actions / Psalm (8.2)

UndefinedInterfaceMethod

src/SonsOfPHP/Bard/src/Console/Command/PushCommand.php:53:61: UndefinedInterfaceMethod: Method Symfony\Component\Console\Helper\HelperInterface::formatSection does not exist (see https://psalm.dev/181)
foreach ($commands as $cmd) {
$process = new Process($cmd);
$io->text($process->getCommandLine());
Expand All @@ -60,6 +60,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
->wait();
}
}

$output->writeln($this->getHelper('formatter')->formatSection($pkgName, '...Done'));

Check failure on line 64 in src/SonsOfPHP/Bard/src/Console/Command/PushCommand.php

View workflow job for this annotation

GitHub Actions / Psalm (8.2)

UndefinedInterfaceMethod

src/SonsOfPHP/Bard/src/Console/Command/PushCommand.php:64:61: UndefinedInterfaceMethod: Method Symfony\Component\Console\Helper\HelperInterface::formatSection does not exist (see https://psalm.dev/181)
$io->newLine();
}

$io->success('All Packages have been published.');
Expand Down
Loading

0 comments on commit a57e46f

Please sign in to comment.