Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bard] Various updates #228

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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...'));
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'));
$io->newLine();
}

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