Skip to content

Commit

Permalink
cs fixes, new functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaEstes committed Sep 30, 2023
1 parent 70e0c9d commit 370ee8b
Show file tree
Hide file tree
Showing 157 changed files with 300 additions and 951 deletions.
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
* text=auto eol=lf

*.conf text eol=lf
*.html text eol=lf
*.ico binary
*.ini text eol=lf
*.js text eol=lf
*.json text eol=lf
*.md text eol=lf
*.php text eol=lf
*.png binary
*.sh text eol=lf
*.yaml text eol=lf
*.yml text eol=lf

/.github export-ignore
/docs export-ignore
/tools export-ignore
Expand Down
21 changes: 2 additions & 19 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,10 @@
$config = new PhpCsFixer\Config();
return $config->setRules([
// Rule sets
'@PER-CS2.0' => true,
'@PHP80Migration:risky' => true,
'@PHP81Migration' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHPUnit84Migration:risky' => true,

// PHPUnit Rules
'php_unit_internal_class' => ['types' => ['normal', 'final']],
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
'php_unit_test_class_requires_covers' => true,

// Rules
'align_multiline_comment' => true,
'phpdoc_line_span' => true,
'phpdoc_order_by_value' => ['annotations' => ['covers', 'throws']],
'phpdoc_order' => true,
'phpdoc_tag_casing' => true,
'array_indentation' => true,
'explicit_indirect_variable' => true,
'binary_operator_spaces' => ['default' => 'align_single_space'],
'phpdoc_to_comment' => false,
'@PHPUnit100Migration:risky' => true,
])
->setFinder($finder)
;
4 changes: 1 addition & 3 deletions packages/bard/src/Console/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
/**
* @author Joshua Estes <[email protected]>
*/
abstract class AbstractCommand extends Command
{
}
abstract class AbstractCommand extends Command {}
18 changes: 2 additions & 16 deletions packages/bard/src/Console/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,23 @@ final class InitCommand extends AbstractCommand
{
protected static $defaultName = 'init';

/**
* {@inheritDoc}
*/
// public function __construct()
// {
// parent::__construct();
// }

/**
* {@inheritDoc}
*/
protected function configure(): void
{
$this
->setDescription('Creates the initial bard.json file')
;
}

/**
* {@inheritDoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output): void
{
}
protected function initialize(InputInterface $input, OutputInterface $output): void {}

/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$filename = $input->getOption('working-dir').'/bard.json';
$filename = $input->getOption('working-dir') . '/bard.json';

if (file_exists($filename)) {
$output->writeln('bard.json file already exists');
Expand Down
18 changes: 2 additions & 16 deletions packages/bard/src/Console/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,23 @@ final class InstallCommand extends AbstractCommand
{
protected static $defaultName = 'install';

/**
* {@inheritDoc}
*/
// public function __construct()
// {
// parent::__construct();
// }

/**
* {@inheritDoc}
*/
protected function configure(): void
{
$this
->setDescription('Runs composer install for all packages')
;
}

/**
* {@inheritDoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output): void
{
}
protected function initialize(InputInterface $input, OutputInterface $output): void {}

/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$bardJsonFile = new JsonFile($input->getOption('working-dir').'/bard.json');
$bardJsonFile = new JsonFile($input->getOption('working-dir') . '/bard.json');
foreach ($bardJsonFile->getSection('packages') as $pkg) {
$process = new Process([
'composer',
Expand Down
19 changes: 5 additions & 14 deletions packages/bard/src/Console/Command/MergeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public function __construct()
parent::__construct();
}

/**
* {@inheritDoc}
*/
protected function configure(): void
{
$this
Expand All @@ -50,12 +47,9 @@ protected function configure(): void
;
}

/**
* {@inheritDoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output): void
{
$bardConfigFile = $input->getOption('working-dir').'/bard.json';
$bardConfigFile = $input->getOption('working-dir') . '/bard.json';
if (!file_exists($bardConfigFile)) {
throw new \RuntimeException(sprintf('"%s" file does not exist', $bardConfigFile));
}
Expand All @@ -64,33 +58,30 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
->objectAsArray()
->decode(file_get_contents($bardConfigFile));

$this->mainComposerFile = $input->getOption('working-dir').'/composer.json';
$this->mainComposerFile = $input->getOption('working-dir') . '/composer.json';
if (!file_exists($this->mainComposerFile)) {
throw new \RuntimeException(sprintf('"%s" file does not exist', $this->mainComposerFile));
}
}

/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->formatter = $this->getHelper('formatter');

$rootComposerJsonFile = new JsonFile($input->getOption('working-dir').'/composer.json');
$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) {
$packageComposerFile = realpath($input->getOption('working-dir').'/'.$pkg['path'].'/composer.json');
$packageComposerFile = realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json');
if (!file_exists($packageComposerFile)) {
$output->writeln(sprintf('No "%s" found, skipping', $packageComposerFile));
continue;
}

$pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir').'/'.$pkg['path'].'/composer.json'));
$pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json'));

$output->writeln($this->formatter->formatSection('bard', sprintf('Merging "%s" into root composer.json', $pkgComposerJsonFile->getSection('name'))));

Expand Down
10 changes: 2 additions & 8 deletions packages/bard/src/Console/Command/PublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ final class PublishCommand extends AbstractCommand
{
protected static $defaultName = 'publish';

/**
* {@inheritDoc}
*/
protected function configure(): void
{
$this
Expand All @@ -33,17 +30,14 @@ protected function configure(): void
;
}

/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$bardConfig = new JsonFile($input->getOption('working-dir').'/bard.json');
$bardConfig = new JsonFile($input->getOption('working-dir') . '/bard.json');
$formatter = $this->getHelper('formatter');
$io = new SymfonyStyle($input, $output);

foreach ($bardConfig->getSection('packages') as $pkg) {
$pkgComposerFile = realpath($input->getOption('working-dir').'/'.$pkg['path'].'/composer.json');
$pkgComposerFile = realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json');
$pkgComposerJsonFile = new JsonFile($pkgComposerFile);
$pkgName = $pkgComposerJsonFile->getSection('name');
$io->text(sprintf('Pushing <info>%s</>', $pkgName));
Expand Down
31 changes: 7 additions & 24 deletions packages/bard/src/Console/Command/ReleaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,11 @@ final class ReleaseCommand extends AbstractCommand
private $releaseVersion;
private bool $isDryRun = true;

/**
* {@inheritDoc}
*/
// public function __construct()
// {
// parent::__construct();
// }

/**
* {@inheritDoc}
*/
protected function configure(): void
{
$this
Expand All @@ -60,17 +54,14 @@ protected function configure(): void
);
}

/**
* {@inheritDoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output): void
{
$version = $input->getArgument('release');
if (null === $version) {
return;
}

$this->bardConfig = new JsonFile($input->getOption('working-dir').'/bard.json');
$this->bardConfig = new JsonFile($input->getOption('working-dir') . '/bard.json');
$currentVersion = new Version($this->bardConfig->getSection('version'));

if (\in_array($version, ['major', 'minor', 'patch'])) {
Expand All @@ -96,16 +87,8 @@ protected function initialize(InputInterface $input, OutputInterface $output): v
$this->isDryRun = $input->getOption('dry-run');
}

/**
* {@inheritDoc}
*/
protected function interact(InputInterface $input, OutputInterface $output): void
{
}
protected function interact(InputInterface $input, OutputInterface $output): void {}

/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$formatter = $this->getHelper('formatter');
Expand All @@ -124,13 +107,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->getHelper('process')->mustRun($output, $process, sprintf('There was and error running command: %s', $process->getCommandLine()));
}

$rootComposerJsonFile = new JsonFile($input->getOption('working-dir').'/composer.json');
$rootComposerJsonFile = new JsonFile($input->getOption('working-dir') . '/composer.json');

// 1. Update "replace" in main composer.json with the Package Names
// "package/name": "self.version"
$io->section('updating root composer.json "replace" section with package information');
foreach ($this->bardConfig->getSection('packages') as $pkg) {
$pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir').'/'.$pkg['path'].'/composer.json'));
$pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json'));
$output->writeln([
$formatter->formatSection($pkgComposerJsonFile->getSection('name'), 'Updating root <info>composer.json</info>'),
]);
Expand Down Expand Up @@ -160,8 +143,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
['git', 'add', '.'],
['git', 'commit', '--allow-empty', '-m', sprintf('"Preparing for Release v%s"', $this->releaseVersion->toString())],
['git', 'push', 'origin', $input->getOption('branch')],
['git', 'tag', 'v'.$this->releaseVersion->toString()],
['git', 'push', 'origin', 'v'.$this->releaseVersion->toString()],
['git', 'tag', 'v' . $this->releaseVersion->toString()],
['git', 'push', 'origin', 'v' . $this->releaseVersion->toString()],
];
foreach ($processCommands as $cmd) {
$process = new Process($cmd);
Expand All @@ -176,7 +159,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io->newLine();
$io->title(sprintf('updating package repos with release %s', $this->releaseVersion->toString()));
foreach ($this->bardConfig->getSection('packages') as $pkg) {
$pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir').'/'.$pkg['path'].'/composer.json'));
$pkgComposerJsonFile = new JsonFile(realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json'));
$pkgName = $pkgComposerJsonFile->getSection('name');
$io->text(sprintf('Package <info>%s</> is being released', $pkgName));
$processCommands = [
Expand Down
18 changes: 2 additions & 16 deletions packages/bard/src/Console/Command/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,23 @@ final class UpdateCommand extends AbstractCommand
{
protected static $defaultName = 'update';

/**
* {@inheritDoc}
*/
// public function __construct()
// {
// parent::__construct();
// }

/**
* {@inheritDoc}
*/
protected function configure(): void
{
$this
->setDescription('Runs composer update for all packages')
;
}

/**
* {@inheritDoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output): void
{
}
protected function initialize(InputInterface $input, OutputInterface $output): void {}

/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$bardJsonFile = new JsonFile($input->getOption('working-dir').'/bard.json');
$bardJsonFile = new JsonFile($input->getOption('working-dir') . '/bard.json');
foreach ($bardJsonFile->getSection('packages') as $pkg) {
$process = new Process([
'composer',
Expand Down
3 changes: 0 additions & 3 deletions packages/bard/src/Worker/File/Bard/UpdateVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ public function __construct(VersionInterface $version)
$this->version = $version;
}

/**
* {@inheritDoc}
*/
public function apply(JsonFile $bardJsonFile): JsonFile
{
return $bardJsonFile->setSection('version', $this->version->toString());
Expand Down
3 changes: 0 additions & 3 deletions packages/bard/src/Worker/File/Composer/Package/Authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public function __construct(JsonFile $rootComposerJsonFile)
$this->rootComposerJsonFile = $rootComposerJsonFile;
}

/**
* {@inheritDoc}
*/
public function apply(JsonFile $pkgComposerJsonFile): JsonFile
{
$rootSection = $this->rootComposerJsonFile->getSection('authors');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public function __construct(JsonFile $rootComposerJsonFile)
$this->rootComposerJsonFile = $rootComposerJsonFile;
}

/**
* {@inheritDoc}
*/
public function apply(JsonFile $pkgComposerJsonFile): JsonFile
{
$rootExtraSection = $this->rootComposerJsonFile->getSection('extra');
Expand Down
3 changes: 0 additions & 3 deletions packages/bard/src/Worker/File/Composer/Package/Funding.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public function __construct(JsonFile $rootComposerJsonFile)
$this->rootComposerJsonFile = $rootComposerJsonFile;
}

/**
* {@inheritDoc}
*/
public function apply(JsonFile $pkgComposerJsonFile): JsonFile
{
$rootSection = $this->rootComposerJsonFile->getSection('funding');
Expand Down
Loading

0 comments on commit 370ee8b

Please sign in to comment.