Skip to content

Commit 96c02b3

Browse files
author
kamiyang
committed
[TASK] Update readme
1 parent c321248 commit 96c02b3

12 files changed

+58
-70
lines changed

Classes/Facade/CommandUtilityFacade.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

Classes/Facade/SystemEnvironmentBuilderFacade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* @internal
1414
* @package KamiYang\ProjectVersion\Facade
1515
* @author Jan Stockfisch <[email protected]>
16-
* @codeCoverageIgnore
1716
*/
1817
class SystemEnvironmentBuilderFacade
1918
{

Classes/Service/ProjectVersionService.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
use KamiYang\ProjectVersion\Configuration\ExtensionConfiguration;
77
use KamiYang\ProjectVersion\Enumeration\GitCommandEnumeration;
88
use KamiYang\ProjectVersion\Enumeration\ProjectVersionModeEnumeration;
9-
use KamiYang\ProjectVersion\Facade\CommandUtilityFacade;
109
use KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade;
1110
use TYPO3\CMS\Core\SingletonInterface;
11+
use TYPO3\CMS\Core\Utility\CommandUtility;
1212
use TYPO3\CMS\Core\Utility\GeneralUtility;
1313

1414
/**
@@ -19,10 +19,6 @@
1919
*/
2020
class ProjectVersionService implements SingletonInterface
2121
{
22-
/**
23-
* @var \KamiYang\ProjectVersion\Facade\CommandUtilityFacade
24-
*/
25-
protected $commandUtilityFacade;
2622

2723
/**
2824
* @var \KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade
@@ -76,11 +72,8 @@ private function setVersionFromFile(ProjectVersion $projectVersion)
7672
*
7773
* @param \KamiYang\ProjectVersion\Facade\CommandUtilityFacade $commandUtilityFacade
7874
*/
79-
public function __construct(
80-
CommandUtilityFacade $commandUtilityFacade,
81-
SystemEnvironmentBuilderFacade $systemEnvironmentBuilderFacade
82-
) {
83-
$this->commandUtilityFacade = $commandUtilityFacade;
75+
public function __construct(SystemEnvironmentBuilderFacade $systemEnvironmentBuilderFacade)
76+
{
8477
$this->systemEnvironmentBuilderFacade = $systemEnvironmentBuilderFacade;
8578
}
8679

@@ -108,7 +101,7 @@ private function isGitAvailable(): bool
108101
{
109102
return $this->systemEnvironmentBuilderFacade->isFunctionDisabled('exec') === false &&
110103
// check if git exists
111-
$this->commandUtilityFacade->exec('git --version', $_, $returnCode) &&
104+
CommandUtility::exec('git --version', $_, $returnCode) &&
112105
$returnCode === 0;
113106
}
114107

@@ -117,9 +110,9 @@ private function isGitAvailable(): bool
117110
*/
118111
private function getVersionByFormat(): string
119112
{
120-
$branch = \trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_BRANCH));
121-
$revision = \trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_REVISION));
122-
$tag = \trim($this->commandUtilityFacade->exec(GitCommandEnumeration::CMD_TAG));
113+
$branch = \trim(CommandUtility::exec(GitCommandEnumeration::CMD_BRANCH));
114+
$revision = \trim(CommandUtility::exec(GitCommandEnumeration::CMD_REVISION));
115+
$tag = \trim(CommandUtility::exec(GitCommandEnumeration::CMD_TAG));
123116

124117
switch (ExtensionConfiguration::getGitFormat()) {
125118
case GitCommandEnumeration::FORMAT_REVISION:
4.13 KB
Loading
Loading
Loading
Loading
Loading
39.1 KB
Loading

README.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ First make sure you match the requirements:
88

99
| Requirement | Version |
1010
| --- | --- |
11-
| TYPO3 | \>= 8.7.0 \<=8.7.15 |
11+
| TYPO3 | \>= 8.7.0 \<=8.7.16 |
1212
| php | \>= 7.0 |
1313

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

46+
### GIT
47+
Since release 0.3.0 git is supported. This must be manually activated. In order to use git, make sure it's available!
48+
Common case is that the local development environment is based on docker images. Many docker images do not have git available.
49+
To activate it, simply move via your preferred web browser into the TYPO3 backend. Go to "Extensions > Project Version" and configure the extension.
50+
The configuration screen will look like this on default:
51+
52+
![default extension configuration](Documentation/Images/DefaultConfig.png)
53+
54+
#### Configuration possibilities
55+
56+
##### basic.mode
57+
58+
| Configuration | Description |
59+
| --- | --- |
60+
| VERSION File (default)| Fetches the current project version based on the path configured in `basic.versionFilePath` |
61+
| GIT | Uses GIT if available to resolve the project version in the format configured in `basic.gitFormat` |
62+
| GIT (VERSION file as fallback) | Will use GIT as preferred resolving method. If not available will fallback to VERSION file. |
63+
64+
65+
##### basic.gitFormat
66+
67+
| Configuration | Description | Example |
68+
| --- | --- | --- |
69+
| Revision | Will only fetch the revision as project version | ![git revision example ](Documentation/Images/BasicGitFormatRevision.png) |
70+
| \[revision] Branch (default) | Will fetch the current revision and branch | ![git revision and branch example ](Documentation/Images/BasicGitFormatRevisionAndBranch.png) |
71+
| \[revision] Tag | Will fetch the current revision and tag | ![git revision and tag example ](Documentation/Images/BasicGitFormatRevisionAndTag.png) |
72+
| Branch | Will only fetch the current branch | ![git branch example ](Documentation/Images/BasicGitFormatRevisionBranch.png) |
73+
| Tag | Will only fetch the current tag | ![git tag example ](Documentation/Images/BasicGitFormatRevisionTag.png) |
74+
4675
## Roadmap to v1.0.0
4776

4877
- [x] Static VERSION file support
4978
- [x] Add ability to configure "VERSION"-file path
50-
- [ ] GIT revision support
51-
- [ ] GIT tag/branch based on revision support
79+
- [x] GIT revision support
80+
- [x] GIT tag/branch based on revision support
5281
- [ ] Add documentation of this extensions features
53-
- [ ] Extension Icon
5482
- [x] Upload extension to packagist.org
5583
- [x] Upload extension to TER
5684

57-
### Milestone for v0.3.0
58-
The next milestone is the integration of basic GIT revisions.
85+
### Milestone for v0.4.0
86+
The next milestone is the documentation of various use cases and possibilities and achieve a higher coverage. Current coverage is about ~70%.

Tests/Unit/Service/ProjectVersionServiceTest.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
use KamiYang\ProjectVersion\Configuration\ExtensionConfiguration;
77
use KamiYang\ProjectVersion\Enumeration\ProjectVersionModeEnumeration;
8-
use KamiYang\ProjectVersion\Facade\CommandUtilityFacade;
98
use KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade;
109
use KamiYang\ProjectVersion\Service\ProjectVersion;
1110
use KamiYang\ProjectVersion\Service\ProjectVersionService;
1211
use Nimut\TestingFramework\TestCase\UnitTestCase;
1312
use Prophecy\Argument;
13+
use Prophecy\Promise\CallbackPromise;
1414
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
1515
use TYPO3\CMS\Core\Utility\GeneralUtility;
1616

@@ -31,20 +31,25 @@ class ProjectVersionServiceTest extends UnitTestCase
3131
'versionFilePath' => 'VERSION',
3232
'mode' => ProjectVersionModeEnumeration::FILE
3333
];
34-
/**
35-
* @var \KamiYang\ProjectVersion\Facade\CommandUtilityFacade|\Prophecy\Prophecy\ObjectProphecy
36-
*/
37-
private $commandUtilityFacadeProphecy;
3834

3935
/**
4036
* @var \KamiYang\ProjectVersion\Facade\SystemEnvironmentBuilderFacade|\Prophecy\Prophecy\ObjectProphecy
4137
*/
4238
private $systemEnvironmentBuilderFacadeProphecy;
4339

40+
private $projectVersionService;
41+
4442
protected function setUp()
4543
{
46-
$this->commandUtilityFacadeProphecy = $this->prophesize(CommandUtilityFacade::class);
4744
$this->systemEnvironmentBuilderFacadeProphecy = $this->prophesize(SystemEnvironmentBuilderFacade::class);
45+
46+
$this->systemEnvironmentBuilderFacadeProphecy->isFunctionDisabled('exec')
47+
->willReturn(false);
48+
49+
50+
$this->subject = new ProjectVersionService(
51+
$this->systemEnvironmentBuilderFacadeProphecy->reveal()
52+
);
4853
}
4954

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

6873
$subject = new ProjectVersionService(
69-
$this->commandUtilityFacadeProphecy->reveal(),
7074
$this->systemEnvironmentBuilderFacadeProphecy->reveal()
7175
);
7276
$subject->getProjectVersion();
@@ -88,11 +92,7 @@ public function getProjectVersionShouldSetVersionFromVersionFileIfFileExists(str
8892
$projectVersionProphecy = $this->prophesize(ProjectVersion::class);
8993
GeneralUtility::setSingletonInstance(ProjectVersion::class, $projectVersionProphecy->reveal());
9094

91-
$subject = new ProjectVersionService(
92-
$this->commandUtilityFacadeProphecy->reveal(),
93-
$this->systemEnvironmentBuilderFacadeProphecy->reveal()
94-
);
95-
$subject->getProjectVersion();
95+
$this->subject->getProjectVersion();
9696

9797
$projectVersionProphecy->setVersion(Argument::containingString('1.0.1'))
9898
->shouldHaveBeenCalledTimes(1);
@@ -119,7 +119,7 @@ public function versionFilePathDataProvider(): array
119119
/**
120120
* @test
121121
*/
122-
public function getProjectVersionShouldNotSetVersionFromGITIfCommandIsNotAvailable()
122+
public function getProjectVersionShouldNotSetVersionFromGitIfCommandExecIsNotAvailable()
123123
{
124124
$this->extensionConfiguration['mode'] = ProjectVersionModeEnumeration::GIT;
125125
$this->setUpExtensionConfiguration();
@@ -131,7 +131,6 @@ public function getProjectVersionShouldNotSetVersionFromGITIfCommandIsNotAvailab
131131
->willReturn(true);
132132

133133
$subject = new ProjectVersionService(
134-
$this->commandUtilityFacadeProphecy->reveal(),
135134
$this->systemEnvironmentBuilderFacadeProphecy->reveal()
136135
);
137136
$subject->getProjectVersion();

phpunit.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
</testsuite>
1313
</testsuites>
1414
<filter>
15-
<whitelist addUncoveredFilesFromWhitelist="true">
15+
<whitelist>
1616
<directory suffix=".php">Classes/</directory>
17+
<exclude>
18+
<directory suffix=".php">Classes/Facade/</directory>
19+
</exclude>
1720
</whitelist>
1821
</filter>
1922
</phpunit>

0 commit comments

Comments
 (0)