Skip to content

Commit

Permalink
[TASK] Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
KamiYang committed Jun 14, 2018
1 parent c321248 commit 96c02b3
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 70 deletions.
34 changes: 0 additions & 34 deletions Classes/Facade/CommandUtilityFacade.php

This file was deleted.

1 change: 0 additions & 1 deletion Classes/Facade/SystemEnvironmentBuilderFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* @internal
* @package KamiYang\ProjectVersion\Facade
* @author Jan Stockfisch <[email protected]>
* @codeCoverageIgnore
*/
class SystemEnvironmentBuilderFacade
{
Expand Down
21 changes: 7 additions & 14 deletions Classes/Service/ProjectVersionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use KamiYang\ProjectVersion\Configuration\ExtensionConfiguration;
use KamiYang\ProjectVersion\Enumeration\GitCommandEnumeration;
use KamiYang\ProjectVersion\Enumeration\ProjectVersionModeEnumeration;
use KamiYang\ProjectVersion\Facade\CommandUtilityFacade;
use KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand All @@ -19,10 +19,6 @@
*/
class ProjectVersionService implements SingletonInterface
{
/**
* @var \KamiYang\ProjectVersion\Facade\CommandUtilityFacade
*/
protected $commandUtilityFacade;

/**
* @var \KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade
Expand Down Expand Up @@ -76,11 +72,8 @@ private function setVersionFromFile(ProjectVersion $projectVersion)
*
* @param \KamiYang\ProjectVersion\Facade\CommandUtilityFacade $commandUtilityFacade
*/
public function __construct(
CommandUtilityFacade $commandUtilityFacade,
SystemEnvironmentBuilderFacade $systemEnvironmentBuilderFacade
) {
$this->commandUtilityFacade = $commandUtilityFacade;
public function __construct(SystemEnvironmentBuilderFacade $systemEnvironmentBuilderFacade)
{
$this->systemEnvironmentBuilderFacade = $systemEnvironmentBuilderFacade;
}

Expand Down Expand Up @@ -108,7 +101,7 @@ private function isGitAvailable(): bool
{
return $this->systemEnvironmentBuilderFacade->isFunctionDisabled('exec') === false &&
// check if git exists
$this->commandUtilityFacade->exec('git --version', $_, $returnCode) &&
CommandUtility::exec('git --version', $_, $returnCode) &&
$returnCode === 0;
}

Expand All @@ -117,9 +110,9 @@ private function isGitAvailable(): bool
*/
private function getVersionByFormat(): string
{
$branch = \trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_BRANCH));
$revision = \trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_REVISION));
$tag = \trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_TAG));
$branch = \trim(CommandUtility::exec(GitCommandEnumeration::CMD_BRANCH));
$revision = \trim(CommandUtility::exec(GitCommandEnumeration::CMD_REVISION));
$tag = \trim(CommandUtility::exec(GitCommandEnumeration::CMD_TAG));

switch (ExtensionConfiguration::getGitFormat()) {
case GitCommandEnumeration::FORMAT_REVISION:
Expand Down
Binary file added Documentation/Images/BasicGitFormatRevision.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/Images/DefaultConfig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ First make sure you match the requirements:

| Requirement | Version |
| --- | --- |
| TYPO3 | \>= 8.7.0 \<=8.7.15 |
| TYPO3 | \>= 8.7.0 \<=8.7.16 |
| php | \>= 7.0 |

### Composer (recommended)
Expand Down Expand Up @@ -43,16 +43,44 @@ We assume that the web document root (`PATH_site`) is `/var/www/html`.
| typo3conf/ | /var/www/html/typo3conf/VERSION |
| ./My/Custom/Version/File/In/Some/Nested/File/Structure | /var/www/html/./My/Custom/Version/File/In/Some/Nested/File/Structure|

### GIT
Since release 0.3.0 git is supported. This must be manually activated. In order to use git, make sure it's available!
Common case is that the local development environment is based on docker images. Many docker images do not have git available.
To activate it, simply move via your preferred web browser into the TYPO3 backend. Go to "Extensions > Project Version" and configure the extension.
The configuration screen will look like this on default:

![default extension configuration](Documentation/Images/DefaultConfig.png)

#### Configuration possibilities

##### basic.mode

| Configuration | Description |
| --- | --- |
| VERSION File (default)| Fetches the current project version based on the path configured in `basic.versionFilePath` |
| GIT | Uses GIT if available to resolve the project version in the format configured in `basic.gitFormat` |
| GIT (VERSION file as fallback) | Will use GIT as preferred resolving method. If not available will fallback to VERSION file. |


##### basic.gitFormat

| Configuration | Description | Example |
| --- | --- | --- |
| Revision | Will only fetch the revision as project version | ![git revision example ](Documentation/Images/BasicGitFormatRevision.png) |
| \[revision] Branch (default) | Will fetch the current revision and branch | ![git revision and branch example ](Documentation/Images/BasicGitFormatRevisionAndBranch.png) |
| \[revision] Tag | Will fetch the current revision and tag | ![git revision and tag example ](Documentation/Images/BasicGitFormatRevisionAndTag.png) |
| Branch | Will only fetch the current branch | ![git branch example ](Documentation/Images/BasicGitFormatRevisionBranch.png) |
| Tag | Will only fetch the current tag | ![git tag example ](Documentation/Images/BasicGitFormatRevisionTag.png) |

## Roadmap to v1.0.0

- [x] Static VERSION file support
- [x] Add ability to configure "VERSION"-file path
- [ ] GIT revision support
- [ ] GIT tag/branch based on revision support
- [x] GIT revision support
- [x] GIT tag/branch based on revision support
- [ ] Add documentation of this extensions features
- [ ] Extension Icon
- [x] Upload extension to packagist.org
- [x] Upload extension to TER

### Milestone for v0.3.0
The next milestone is the integration of basic GIT revisions.
### Milestone for v0.4.0
The next milestone is the documentation of various use cases and possibilities and achieve a higher coverage. Current coverage is about ~70%.
27 changes: 13 additions & 14 deletions Tests/Unit/Service/ProjectVersionServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

use KamiYang\ProjectVersion\Configuration\ExtensionConfiguration;
use KamiYang\ProjectVersion\Enumeration\ProjectVersionModeEnumeration;
use KamiYang\ProjectVersion\Facade\CommandUtilityFacade;
use KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade;
use KamiYang\ProjectVersion\Service\ProjectVersion;
use KamiYang\ProjectVersion\Service\ProjectVersionService;
use Nimut\TestingFramework\TestCase\UnitTestCase;
use Prophecy\Argument;
use Prophecy\Promise\CallbackPromise;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand All @@ -31,20 +31,25 @@ class ProjectVersionServiceTest extends UnitTestCase
'versionFilePath' => 'VERSION',
'mode' => ProjectVersionModeEnumeration::FILE
];
/**
* @var \KamiYang\ProjectVersion\Facade\CommandUtilityFacade|\Prophecy\Prophecy\ObjectProphecy
*/
private $commandUtilityFacadeProphecy;

/**
* @var \KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade|\Prophecy\Prophecy\ObjectProphecy
*/
private $systemEnvironmentBuilderFacadeProphecy;

private $projectVersionService;

protected function setUp()
{
$this->commandUtilityFacadeProphecy = $this->prophesize(CommandUtilityFacade::class);
$this->systemEnvironmentBuilderFacadeProphecy = $this->prophesize(SystemEnvironmentBuilderFacade::class);

$this->systemEnvironmentBuilderFacadeProphecy->isFunctionDisabled('exec')
->willReturn(false);


$this->subject = new ProjectVersionService(
$this->systemEnvironmentBuilderFacadeProphecy->reveal()
);
}

protected function tearDown()
Expand All @@ -66,7 +71,6 @@ public function getProjectVersionShouldNotSetProjectVersionIfVersionFileIsNotFou
GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersionProphecy->reveal());

$subject = new ProjectVersionService(
$this->commandUtilityFacadeProphecy->reveal(),
$this->systemEnvironmentBuilderFacadeProphecy->reveal()
);
$subject->getProjectVersion();
Expand All @@ -88,11 +92,7 @@ public function getProjectVersionShouldSetVersionFromVersionFileIfFileExists(str
$projectVersionProphecy = $this->prophesize(ProjectVersion::class);
GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersionProphecy->reveal());

$subject = new ProjectVersionService(
$this->commandUtilityFacadeProphecy->reveal(),
$this->systemEnvironmentBuilderFacadeProphecy->reveal()
);
$subject->getProjectVersion();
$this->subject->getProjectVersion();

$projectVersionProphecy->setVersion(Argument::containingString('1.0.1'))
->shouldHaveBeenCalledTimes(1);
Expand All @@ -119,7 +119,7 @@ public function versionFilePathDataProvider(): array
/**
* @test
*/
public function getProjectVersionShouldNotSetVersionFromGITIfCommandIsNotAvailable()
public function getProjectVersionShouldNotSetVersionFromGitIfCommandExecIsNotAvailable()
{
$this->extensionConfiguration['mode'] = ProjectVersionModeEnumeration::GIT;
$this->setUpExtensionConfiguration();
Expand All @@ -131,7 +131,6 @@ public function getProjectVersionShouldNotSetVersionFromGITIfCommandIsNotAvailab
->willReturn(true);

$subject = new ProjectVersionService(
$this->commandUtilityFacadeProphecy->reveal(),
$this->systemEnvironmentBuilderFacadeProphecy->reveal()
);
$subject->getProjectVersion();
Expand Down
5 changes: 4 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<whitelist>
<directory suffix=".php">Classes/</directory>
<exclude>
<directory suffix=".php">Classes/Facade/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

0 comments on commit 96c02b3

Please sign in to comment.