Skip to content

Commit a57e46f

Browse files
authored
[Bard] Various updates (#228)
1 parent b67565d commit a57e46f

16 files changed

Lines changed: 348 additions & 244 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ To get the diff between two versions, go to https://github.com/SonsOfPHP/sonsofp
1010

1111
## [Unreleased]
1212

13+
* [PR #228](https://github.com/SonsOfPHP/sonsofphp/pull/228) [Bard] Various updates
1314
* [PR #227](https://github.com/SonsOfPHP/sonsofphp/pull/227) [Cache] FilesystemAdapter, Marshallers, and other updates
1415
* [PR #226](https://github.com/SonsOfPHP/sonsofphp/pull/226) [Registry] New Component and Contract
1516
* [PR #225](https://github.com/SonsOfPHP/sonsofphp/pull/225) Maintenance

composer.json

Lines changed: 140 additions & 124 deletions
Large diffs are not rendered by default.

src/SonsOfPHP/Bard/dist/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.phar

src/SonsOfPHP/Bard/src/Console/Command/MergeCommand.php

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
use SonsOfPHP\Bard\Worker\File\Composer\Package\BranchAlias;
1111
use SonsOfPHP\Bard\Worker\File\Composer\Package\Funding;
1212
use SonsOfPHP\Bard\Worker\File\Composer\Package\Support;
13+
use SonsOfPHP\Bard\Worker\File\Composer\Root\ClearSection;
1314
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadDevSection;
1415
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadSection;
1516
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateProvideSection;
1617
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateReplaceSection;
1718
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireDevSection;
1819
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireSection;
19-
use SonsOfPHP\Component\Json\Json;
2020
use Symfony\Component\Console\Helper\HelperInterface;
2121
use Symfony\Component\Console\Input\InputArgument;
2222
use Symfony\Component\Console\Input\InputInterface;
@@ -31,21 +31,12 @@
3131
*/
3232
final class MergeCommand extends AbstractCommand
3333
{
34-
private readonly Json $json;
35-
36-
private array $bardConfig;
34+
private JsonFile $bardConfig;
3735

3836
private string $mainComposerFile;
3937

4038
private ?HelperInterface $formatter = null;
4139

42-
public function __construct()
43-
{
44-
$this->json = new Json();
45-
46-
parent::__construct();
47-
}
48-
4940
protected function configure(): void
5041
{
5142
$this
@@ -63,9 +54,7 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
6354
throw new RuntimeException(sprintf('"%s" file does not exist', $bardConfigFile));
6455
}
6556

66-
$this->bardConfig = $this->json->getDecoder()
67-
->objectAsArray()
68-
->decode(file_get_contents($bardConfigFile));
57+
$this->bardConfig = new JsonFile($bardConfigFile);
6958

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

8574
// Clean out a few of the sections in root composer.json file
86-
$rootComposerJsonFile = $rootComposerJsonFile->setSection('autoload', []);
87-
$rootComposerJsonFile = $rootComposerJsonFile->setSection('autoload-dev', []);
88-
89-
foreach ($this->bardConfig['packages'] as $pkg) {
75+
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('autoload'));
76+
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('autoload-dev'));
77+
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('require'));
78+
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('require-dev'));
79+
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('replace'));
80+
$rootComposerJsonFile = $rootComposerJsonFile->with(new ClearSection('provide'));
81+
82+
foreach ($this->bardConfig->getSection('packages') as $pkg) {
9083
$pkgComposerFile = realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json');
9184
if (!file_exists($pkgComposerFile)) {
9285
$output->writeln(sprintf('No "%s" found, skipping', $packageComposerFile));

src/SonsOfPHP/Bard/src/Console/Command/PushCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5050
['git', 'subtree', 'push', '-P', $pkg['path'], $pkg['repository'], $input->getOption('branch')],
5151
];
5252

53-
$io->text(sprintf('Pushing <info>%s</>', $pkgName));
53+
$output->writeln($this->getHelper('formatter')->formatSection($pkgName, 'Pushing...'));
5454
foreach ($commands as $cmd) {
5555
$process = new Process($cmd);
5656
$io->text($process->getCommandLine());
@@ -60,6 +60,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6060
->wait();
6161
}
6262
}
63+
64+
$output->writeln($this->getHelper('formatter')->formatSection($pkgName, '...Done'));
65+
$io->newLine();
6366
}
6467

6568
$io->success('All Packages have been published.');

0 commit comments

Comments
 (0)