Skip to content

Commit

Permalink
Housekeeping (#203)
Browse files Browse the repository at this point in the history
## Description



## Checklist
- [ ] Updated CHANGELOG files
- [ ] Updated Documentation
- [ ] Unit Tests Created
- [ ] php-cs-fixer
  • Loading branch information
JoshuaEstes authored Dec 28, 2023
1 parent 9cd723e commit 5ad14f5
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 34 deletions.
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"minimum-stability": "dev",
"keywords": [
"php",
"sonsofphp",
"sons of php",
"mother repo"
],
Expand Down Expand Up @@ -213,9 +214,7 @@
"symfony/serializer": "^5 || ^6",
"symfony/phpunit-bridge": "^6 || ^7",
"symfony/error-handler": "^6",
"symfony/messenger": "^5 || ^6",
"phpunit/phpunit": "^10.4",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
"phpunit/phpunit": "^10.4"
},
"autoload-dev": {
"psr-4": {
Expand Down
6 changes: 3 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

<testsuites>
<testsuite name="all">
<!--<directory>src/SonsOfPHP/Bard/src/Tests</directory>-->
<directory>src/SonsOfPHP/Bard/Tests</directory>
<directory>src/SonsOfPHP/Bridge/*/*/Tests</directory>
<directory>src/SonsOfPHP/Bridge/*/*/*/Tests</directory>
<directory>src/SonsOfPHP/Bundle/*/Tests</directory>
<directory>src/SonsOfPHP/Component/*/Tests</directory>
</testsuite>

<testsuite name="bard">
<!--<directory>src/SonsOfPHP/Bard/src/Tests</directory>-->
<directory>src/SonsOfPHP/Bard/Tests</directory>
</testsuite>

<testsuite name="cache">
Expand Down Expand Up @@ -111,7 +111,7 @@
<directory>src/*</directory>
</include>
<exclude>
<!--<directory>src/SonsOfPHP/Bard/src/Tests</directory>-->
<directory>src/SonsOfPHP/Bard/Tests</directory>
<directory>src/SonsOfPHP/Bard/vendor</directory>
<directory>src/SonsOfPHP/Bridge/*/*/*/Tests</directory>
<directory>src/SonsOfPHP/Bridge/*/*/*/vendor</directory>
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bard/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/Tests export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
3 changes: 3 additions & 0 deletions src/SonsOfPHP/Bard/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
composer.lock
phpunit.xml
vendor/
44 changes: 44 additions & 0 deletions src/SonsOfPHP/Bard/Tests/JsonFileTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Bard\Tests;

use PHPUnit\Framework\TestCase;
use SonsOfPHP\Bard\JsonFile;

/**
* @coversDefaultClass \SonsOfPHP\Bard\JsonFile
*
* @uses \SonsOfPHP\Bard\JsonFile
* @uses \SonsOfPHP\Component\Json\AbstractEncoderDecoder
* @uses \SonsOfPHP\Component\Json\Json
* @uses \SonsOfPHP\Component\Json\JsonDecoder
*/
final class JsonFileTest extends TestCase
{
/**
* @covers ::__construct
* @covers ::load
* @covers ::getFilename
* @covers ::getSection
*/
public function testGetFilename(): void
{
$json = new JsonFile(__DIR__ . '/fixtures/test.json');

$this->assertIsString($json->getFilename());
}

/**
* @covers ::__construct
* @covers ::load
* @covers ::getSection
*/
public function testGetSection(): void
{
$json = new JsonFile(__DIR__ . '/fixtures/test.json');

$this->assertSame('1.2.3', $json->getSection('version'));
}
}
9 changes: 9 additions & 0 deletions src/SonsOfPHP/Bard/Tests/fixtures/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": "1.2.3",
"packages": [
{
"path": "path/to/Repo",
"repository": "git@github.com:SonsOfPHP/read-only-repo.git"
}
]
}
2 changes: 1 addition & 1 deletion src/SonsOfPHP/Bard/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
"url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp"
}
]
}
}
12 changes: 6 additions & 6 deletions src/SonsOfPHP/Bard/src/Console/Command/AddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ protected function configure(): void
->addArgument('repository', InputArgument::REQUIRED, 'Repository Uri')
->setHelp(
<<<'HELP'
The <info>add</info> command will add additional repositories that need to be managed
into the `bard.json` file.
The <info>add</info> command will add additional repositories that need to be managed
into the `bard.json` file.
Examples:
Examples:
<comment>%command.full_name% src/SonsOfPHP/Bard git@github.com:vendor/package.git</comment>
<comment>%command.full_name% src/SonsOfPHP/Bard git@github.com:vendor/package.git</comment>
Read more at https://docs.sonsofphp.com/bard/
HELP
Read more at https://docs.sonsofphp.com/bard/
HELP
)
;
}
Expand Down
12 changes: 6 additions & 6 deletions src/SonsOfPHP/Bard/src/Console/Command/CopyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ protected function configure(): void
->addArgument('package', InputArgument::OPTIONAL, 'Which package?')
->setHelp(
<<<'HELP'
The <info>copy</info> command will copy whatever file you give it to all the other
repositories it is managing. This is useful for LICENSE files.
The <info>copy</info> command will copy whatever file you give it to all the other
repositories it is managing. This is useful for LICENSE files.
Examples:
Examples:
<comment>%command.full_name% LICENSE</comment>
<comment>%command.full_name% LICENSE</comment>
Read more at https://docs.sonsofphp.com/bard/
HELP
Read more at https://docs.sonsofphp.com/bard/
HELP
)
;
}
Expand Down
14 changes: 7 additions & 7 deletions src/SonsOfPHP/Bard/src/Console/Command/ReleaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ protected function configure(): void
->addArgument('release', InputArgument::REQUIRED, 'Next Release you want to start? Use format <major>.<minor>.<patch>-<PreRelease>+<BuildMetadata> or "major", "minor", "patch"')
->setHelp(
<<<'EOT'
This command allows you to create a new release and will update the various
repos that have been configured. The current version can be found in the
`bard.json` file. This will will update the version based on the type of release
that you are doing.
This command allows you to create a new release and will update the various
repos that have been configured. The current version can be found in the
`bard.json` file. This will will update the version based on the type of release
that you are doing.
<comment>%command.full_name%</comment>
<comment>%command.full_name%</comment>
Read more at https://docs.SonsOfPHP.com
EOT
Read more at https://docs.SonsOfPHP.com
EOT
);
}

Expand Down
17 changes: 9 additions & 8 deletions src/SonsOfPHP/Bard/src/JsonFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ public function getFilename(): string
}

/**
* Grabs and returns a section from the JSON file
*
* @return array|int|string|null
*/
public function getSection(string $section)
public function getSection(string $section): mixed
{
if (!isset($this->config)) {
$this->load();
Expand All @@ -51,6 +53,8 @@ public function getSection(string $section)
return null;
}

/**
*/
public function setSection(string $section, $value): self
{
if (!isset($this->config)) {
Expand All @@ -63,6 +67,8 @@ public function setSection(string $section, $value): self
return $clone;
}

/**
*/
public function toJson(): string
{
return $this->json->getEncoder()
Expand All @@ -73,13 +79,8 @@ public function toJson(): string
}

/**
* The idea is something like this
* $newRootComposerJsonFile = $rootComposerJsonFile->with($updateReplaceSection, $pkgComposerJsonFile);
* or
* $newRootComposerJsonFile = $rootComposerJsonFile->with($bumpBranchAlias);.
*
* Can even use this for the package composer.json file
* $newPkgComposerJsonFile = $pkgComposerJsonFile->with($updateSupportSection, $rootComposerJsonFile);
* $operator = new Operator();
* $jsonFile->with(new ExampleOperator());
*/
public function with($operator): self
{
Expand Down

0 comments on commit 5ad14f5

Please sign in to comment.