Skip to content

Commit

Permalink
Merge pull request #37 from DoclerLabs/generatorVersionToReadme
Browse files Browse the repository at this point in the history
Add generator version to readme
  • Loading branch information
vsouz4 committed May 19, 2021
2 parents 95b81a8 + 0d82f35 commit b8b0ed5
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 3 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ vendor
.phpunit.result.cache
phpstan.neon
phpunit.xml
build
.php_cs.cache
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [5.6.0] - 2021-05-10
### Added
- Api Client Generator version to README generation

## [5.5.0] - 2021-04-27
### Added
- Support for `default` property on required request parameters.
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ RUN composer install

FROM php:7.4-cli-alpine

ARG API_CLIENT_GENERATOR_VERSION
ENV API_CLIENT_GENERATOR_VERSION=$API_CLIENT_GENERATOR_VERSION

COPY . /generator
COPY --from=dependencies /dependencies/vendor /generator/vendor

Expand Down
3 changes: 3 additions & 0 deletions hooks/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

docker build --build-arg API_CLIENT_GENERATOR_VERSION=`git describe --tags` -f $DOCKERFILE_PATH -t $IMAGE_NAME .
8 changes: 8 additions & 0 deletions src/Input/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Configuration
private string $codeStyleConfig;
private string $packageName;
private string $phpVersion;
private ?string $generatorVersion;
private string $composerJsonTemplateDir;
private string $readmeMdTemplateDir;
private string $httpMessage;
Expand All @@ -37,6 +38,7 @@ public function __construct(
string $codeStyleConfig,
string $packageName,
string $phpVersion,
?string $generatorVersion,
string $composerJsonTemplateDir,
string $readmeMdTemplateDir,
string $httpMessage,
Expand All @@ -61,6 +63,7 @@ public function __construct(
$this->codeStyleConfig = $codeStyleConfig;
$this->packageName = $packageName;
$this->phpVersion = $phpVersion;
$this->generatorVersion = $generatorVersion;
$this->composerJsonTemplateDir = $composerJsonTemplateDir;
$this->readmeMdTemplateDir = $readmeMdTemplateDir;
$this->httpMessage = $httpMessage;
Expand Down Expand Up @@ -102,6 +105,11 @@ public function getPhpVersion(): string
return $this->phpVersion;
}

public function getGeneratorVersion(): ?string
{
return $this->generatorVersion;
}

public function getComposerJsonTemplateDir(): string
{
return $this->composerJsonTemplateDir;
Expand Down
1 change: 1 addition & 0 deletions src/Meta/ReadmeMdTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function render(Specification $specification, MetaFileCollection $fileReg
'specification' => $specification,
'packageName' => $this->configuration->getPackageName(),
'phpVersion' => $this->configuration->getPhpVersion(),
'generatorVersion' => $this->configuration->getGeneratorVersion(),
'namespace' => $this->configuration->getBaseNamespace(),
'exampleOperation' => $this->pickExampleOperation($specification),
'operationsGroupedByTags' => $this->groupOperationsByTags($specification),
Expand Down
1 change: 1 addition & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function register(Container $pimple): void
getenv('CODE_STYLE') ?: Configuration::DEFAULT_CODE_STYLE_CONFIG,
getenv('PACKAGE') ?: '',
getenv('CLIENT_PHP_VERSION') ?: Configuration::DEFAULT_PHP_VERSION,
getenv('API_CLIENT_GENERATOR_VERSION') ?: null,
getenv('COMPOSER_JSON_TEMPLATE_DIR') ?: Configuration::DEFAULT_TEMPLATE_DIRECTORY,
getenv('README_MD_TEMPLATE_DIR') ?: Configuration::DEFAULT_TEMPLATE_DIRECTORY,
getenv('HTTP_MESSAGE') ?: Configuration::DEFAULT_HTTP_MESSAGE,
Expand Down
2 changes: 1 addition & 1 deletion template/README.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docker run -it \
-e OUTPUT_DIR=/client \
-e PACKAGE={{ packageName }} \
-e CLIENT_PHP_VERSION={{ phpVersion }} \
dhlabs/api-client-generator
dhlabs/api-client-generator{{ generatorVersion is not empty ? ":#{generatorVersion}" }}
```

## Usage
Expand Down
3 changes: 3 additions & 0 deletions test/suite/functional/ConfigurationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ConfigurationBuilder
private string $codeStyleConfig;
private string $packageName;
private string $phpVersion;
private string $generatorVersion;
private string $composerJsonTemplateDir;
private string $readmeMdTemplateDir;
private string $httpMessage;
Expand All @@ -27,6 +28,7 @@ private function __construct()
$this->codeStyleConfig = __DIR__ . '/../../../.php_cs.php';
$this->packageName = 'test/test-api-client';
$this->phpVersion = Configuration::DEFAULT_PHP_VERSION;
$this->generatorVersion = '5.6.0';
$this->composerJsonTemplateDir = Configuration::DEFAULT_TEMPLATE_DIRECTORY;
$this->readmeMdTemplateDir = Configuration::DEFAULT_TEMPLATE_DIRECTORY;
$this->httpMessage = Configuration::DEFAULT_HTTP_MESSAGE;
Expand Down Expand Up @@ -125,6 +127,7 @@ public function build(): Configuration
$this->codeStyleConfig,
$this->packageName,
$this->phpVersion,
$this->generatorVersion,
$this->composerJsonTemplateDir,
$this->readmeMdTemplateDir,
$this->httpMessage,
Expand Down
2 changes: 1 addition & 1 deletion test/suite/functional/Meta/ReadmeMd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ docker run -it \
-e OUTPUT_DIR=/client \
-e PACKAGE=test/test-api-client \
-e CLIENT_PHP_VERSION=7.4 \
dhlabs/api-client-generator
dhlabs/api-client-generator:5.6.0
```

## Usage
Expand Down
4 changes: 4 additions & 0 deletions test/suite/unit/Input/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function testValidConfiguration(
string $codeStyleConfig,
string $packageName,
string $phpVersion,
string $generatorVersion,
string $composerJsonTemplateDir,
string $readmeMdTemplateDir,
string $httpMessage,
Expand All @@ -34,6 +35,7 @@ public function testValidConfiguration(
$codeStyleConfig,
$packageName,
$phpVersion,
$generatorVersion,
$composerJsonTemplateDir,
$readmeMdTemplateDir,
$httpMessage,
Expand All @@ -47,6 +49,7 @@ public function testValidConfiguration(
self::assertEquals($codeStyleConfig, $sut->getCodeStyleConfig());
self::assertEquals($packageName, $sut->getPackageName());
self::assertEquals($phpVersion, $sut->getPhpVersion());
self::assertEquals($generatorVersion, $sut->getGeneratorVersion());
self::assertEquals($composerJsonTemplateDir, $sut->getComposerJsonTemplateDir());
self::assertEquals($readmeMdTemplateDir, $sut->getReadmeMdTemplateDir());
self::assertEquals($httpMessage, $sut->getHttpMessage());
Expand All @@ -64,6 +67,7 @@ public function validConfigurationOptions(): array
'/dir/.php_cs.php',
'test/test-api-client',
'7.1',
'5.6.0',
__DIR__,
__DIR__,
Configuration::DEFAULT_HTTP_MESSAGE,
Expand Down

0 comments on commit b8b0ed5

Please sign in to comment.