Add CS Fixer
This commit is contained in:
parent
5cab89b06f
commit
456fbdc101
11 changed files with 427 additions and 92 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
vendor/
|
||||
docker.lock
|
||||
bin/
|
||||
!bin/dcv
|
||||
|
|
11
.php_cs
Normal file
11
.php_cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
$finder = Symfony\CS\Finder\DefaultFinder::create()
|
||||
->exclude('somedir')
|
||||
->in(__DIR__.DIRECTORY_SEPARATOR.'src')
|
||||
->in(__DIR__.DIRECTORY_SEPARATOR.'spec')
|
||||
;
|
||||
|
||||
return Symfony\CS\Config\Config::create()
|
||||
->finder($finder)
|
||||
;
|
12
Makefile
12
Makefile
|
@ -5,13 +5,21 @@ COMPOSERFLAGS ?=
|
|||
DOCKER ?= docker
|
||||
PHP ?= php
|
||||
|
||||
.PHONY: clean docker test
|
||||
.PHONY: clean docker test unit cs fix-cs
|
||||
|
||||
docker: docker.lock
|
||||
|
||||
test: vendor
|
||||
test: vendor unit cs
|
||||
|
||||
unit: vendor
|
||||
$(PHP) bin/kahlan --pattern='*.php' --reporter=verbose --persistent=false --cc=true
|
||||
|
||||
cs:
|
||||
$(PHP) bin/php-cs-fixer fix --dry-run
|
||||
|
||||
fix-cs
|
||||
$(PHP) bin/php-cs-fixer fix
|
||||
|
||||
clean:
|
||||
rm -rf vendor/
|
||||
|
||||
|
|
48
bin/kahlan
48
bin/kahlan
|
@ -1,48 +0,0 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
$autoloaders = [];
|
||||
|
||||
$vendorDir = 'vendor';
|
||||
|
||||
if ($composerPath = realpath(getcwd() . '/composer.json')) {
|
||||
$composerJson = json_decode(file_get_contents($composerPath), true);
|
||||
$vendorDir = isset($composerJson['vendor-dir']) ? $composerJson['vendor-dir'] : $vendorDir;
|
||||
}
|
||||
|
||||
if ($relative = realpath(getcwd() . "/{$vendorDir}/autoload.php")) {
|
||||
$autoloaders[] = include $relative;
|
||||
}
|
||||
|
||||
if (!$absolute = realpath(__DIR__ . '/../../../autoload.php')) {
|
||||
$absolute = realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
}
|
||||
|
||||
if ($absolute && $relative !== $absolute) {
|
||||
$autoloaders[] = include $absolute;
|
||||
}
|
||||
|
||||
if (!$autoloaders) {
|
||||
echo "\033[1;31mYou need to set up the project dependencies using the following commands: \033[0m" . PHP_EOL;
|
||||
echo 'curl -s http://getcomposer.org/installer | php' . PHP_EOL;
|
||||
echo 'php composer.phar install' . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
use Kahlan\Box\Box;
|
||||
use Kahlan\Suite;
|
||||
use Kahlan\Matcher;
|
||||
use Kahlan\Cli\Kahlan;
|
||||
|
||||
$box = box('kahlan', new Box());
|
||||
|
||||
$box->service('suite.global', function() {
|
||||
return new Suite();
|
||||
});
|
||||
|
||||
$specs = new Kahlan([
|
||||
'autoloader' => reset($autoloaders),
|
||||
'suite' => $box->get('suite.global')
|
||||
]);
|
||||
$specs->loadConfig($argv);
|
||||
$specs->run();
|
||||
exit($specs->status());
|
|
@ -8,7 +8,8 @@
|
|||
"graphp/graphviz": "^0.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"crysalead/kahlan": "^2.5.4"
|
||||
"crysalead/kahlan": "^2.5.4",
|
||||
"friendsofphp/php-cs-fixer": "^1.11"
|
||||
},
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
|
|
370
composer.lock
generated
370
composer.lock
generated
|
@ -4,8 +4,8 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "466baff14323f499d4a7257cdd2805bb",
|
||||
"content-hash": "4685875c2d24d2ba11ca3ff77293a406",
|
||||
"hash": "696a6b3b1a107635fb32ba218a89999b",
|
||||
"content-hash": "507a2cc5a9d6155e47cca472793790e0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "clue/graph",
|
||||
|
@ -364,6 +364,372 @@
|
|||
"unit test"
|
||||
],
|
||||
"time": "2016-06-15 15:07:49"
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v1.11.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
|
||||
"reference": "41dc93abd2937a85a3889e28765231d574d2bac8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/41dc93abd2937a85a3889e28765231d574d2bac8",
|
||||
"reference": "41dc93abd2937a85a3889e28765231d574d2bac8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-tokenizer": "*",
|
||||
"php": ">=5.3.6",
|
||||
"sebastian/diff": "~1.1",
|
||||
"symfony/console": "~2.3|~3.0",
|
||||
"symfony/event-dispatcher": "~2.1|~3.0",
|
||||
"symfony/filesystem": "~2.1|~3.0",
|
||||
"symfony/finder": "~2.1|~3.0",
|
||||
"symfony/process": "~2.3|~3.0",
|
||||
"symfony/stopwatch": "~2.5|~3.0"
|
||||
},
|
||||
"conflict": {
|
||||
"hhvm": "<3.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.5|^5",
|
||||
"satooshi/php-coveralls": "^0.7.1"
|
||||
},
|
||||
"bin": [
|
||||
"php-cs-fixer"
|
||||
],
|
||||
"type": "application",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\CS\\": "Symfony/CS/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dariusz Rumiński",
|
||||
"email": "dariusz.ruminski@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "A tool to automatically fix PHP code style",
|
||||
"time": "2016-07-22 06:46:28"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/diff",
|
||||
"version": "1.4.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/diff.git",
|
||||
"reference": "13edfd8706462032c2f52b4b862974dd46b71c9e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e",
|
||||
"reference": "13edfd8706462032c2f52b4b862974dd46b71c9e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.8"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kore Nordmann",
|
||||
"email": "mail@kore-nordmann.de"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
}
|
||||
],
|
||||
"description": "Diff implementation",
|
||||
"homepage": "https://github.com/sebastianbergmann/diff",
|
||||
"keywords": [
|
||||
"diff"
|
||||
],
|
||||
"time": "2015-12-08 07:14:41"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v3.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
"reference": "c0c00c80b3a69132c4e55c3e7db32b4a387615e5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/c0c00c80b3a69132c4e55c3e7db32b4a387615e5",
|
||||
"reference": "c0c00c80b3a69132c4e55c3e7db32b4a387615e5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"psr/log": "~1.0",
|
||||
"symfony/config": "~2.8|~3.0",
|
||||
"symfony/dependency-injection": "~2.8|~3.0",
|
||||
"symfony/expression-language": "~2.8|~3.0",
|
||||
"symfony/stopwatch": "~2.8|~3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/dependency-injection": "",
|
||||
"symfony/http-kernel": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\EventDispatcher\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony EventDispatcher Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2016-07-19 10:45:57"
|
||||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
"version": "v3.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/filesystem.git",
|
||||
"reference": "bb29adceb552d202b6416ede373529338136e84f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/filesystem/zipball/bb29adceb552d202b6416ede373529338136e84f",
|
||||
"reference": "bb29adceb552d202b6416ede373529338136e84f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Filesystem\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Filesystem Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2016-07-20 05:44:26"
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v3.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/finder.git",
|
||||
"reference": "8201978de88a9fa0923e18601bb17f1df9c721e7"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/finder/zipball/8201978de88a9fa0923e18601bb17f1df9c721e7",
|
||||
"reference": "8201978de88a9fa0923e18601bb17f1df9c721e7",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Finder\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Finder Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2016-06-29 05:41:56"
|
||||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v3.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "04c2dfaae4ec56a5c677b0c69fac34637d815758"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/04c2dfaae4ec56a5c677b0c69fac34637d815758",
|
||||
"reference": "04c2dfaae4ec56a5c677b0c69fac34637d815758",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Process\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Process Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2016-07-28 11:13:48"
|
||||
},
|
||||
{
|
||||
"name": "symfony/stopwatch",
|
||||
"version": "v3.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/stopwatch.git",
|
||||
"reference": "bb42806b12c5f89db4ebf64af6741afe6d8457e1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/bb42806b12c5f89db4ebf64af6741afe6d8457e1",
|
||||
"reference": "bb42806b12c5f89db4ebf64af6741afe6d8457e1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Stopwatch\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony Stopwatch Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2016-06-29 05:41:56"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
use function PMSIpilot\DockerComposeViz\fetchServices;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
describe('Fetching services', function() {
|
||||
describe('from a version 1 configuration', function() {
|
||||
it('should fetch services from top-level keys', function() {
|
||||
describe('Fetching services', function () {
|
||||
describe('from a version 1 configuration', function () {
|
||||
it('should fetch services from top-level keys', function () {
|
||||
$configuration = ['foo' => ['image' => 'bar'], 'baz' => ['build' => '.']];
|
||||
|
||||
expect(fetchServices($configuration))->toBe($configuration);
|
||||
});
|
||||
});
|
||||
|
||||
describe('from a version 2 configuration', function() {
|
||||
it('should fetch services from the dedicated section', function() {
|
||||
describe('from a version 2 configuration', function () {
|
||||
it('should fetch services from the dedicated section', function () {
|
||||
$configuration = ['version' => 2, 'services' => ['foo' => ['image' => 'bar'], 'baz' => ['build' => '.']]];
|
||||
|
||||
expect(fetchServices($configuration))->toBe($configuration['services']);
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
use function PMSIpilot\DockerComposeViz\fetchVolumes;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
describe('Fetching volumes', function() {
|
||||
describe('from a version 1 configuration', function() {
|
||||
it('should always return an empty array', function() {
|
||||
describe('Fetching volumes', function () {
|
||||
describe('from a version 1 configuration', function () {
|
||||
it('should always return an empty array', function () {
|
||||
$configuration = ['volumes' => ['image' => 'bar']];
|
||||
|
||||
expect(fetchVolumes($configuration))->toBe([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('from a version 2 configuration', function() {
|
||||
it('should fetch volumes from the dedicated section', function() {
|
||||
describe('from a version 2 configuration', function () {
|
||||
it('should fetch volumes from the dedicated section', function () {
|
||||
$configuration = ['version' => 2, 'volumes' => ['foo' => [], 'bar' => []]];
|
||||
|
||||
expect(fetchVolumes($configuration))->toBe($configuration['volumes']);
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
|
||||
use function PMSIpilot\DockerComposeViz\readConfiguration;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
describe('Reading configuration', function() {
|
||||
it('should check if file exists', function() {
|
||||
expect(function() { readConfiguration(uniqid()); })
|
||||
describe('Reading configuration', function () {
|
||||
it('should check if file exists', function () {
|
||||
expect(function () { readConfiguration(uniqid()); })
|
||||
->toThrow(new InvalidArgumentException());
|
||||
});
|
||||
|
||||
it('should parse YAML and return an array', function() {
|
||||
it('should parse YAML and return an array', function () {
|
||||
expect(readConfiguration(__DIR__.'/fixtures/read-configuration/valid.yml'))
|
||||
->toBe(['version' => 2, 'services' => ['foo' => ['image' => 'bar']]]);
|
||||
});
|
||||
|
||||
it('should report if YAML is invalid', function() {
|
||||
expect(function() { readConfiguration(__DIR__.'/fixtures/read-configuration/invalid.json'); })
|
||||
it('should report if YAML is invalid', function () {
|
||||
expect(function () { readConfiguration(__DIR__.'/fixtures/read-configuration/invalid.json'); })
|
||||
->toThrow(new InvalidArgumentException());
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,21 +4,17 @@ namespace PMSIpilot\DockerComposeViz;
|
|||
|
||||
use Graphp\GraphViz\GraphViz;
|
||||
use Symfony\Component\Console;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
use function PMSIpilot\DockerComposeViz\{
|
||||
readConfiguration,
|
||||
fetchServices,
|
||||
fetchVolumes,
|
||||
fetchNetworks,
|
||||
createGraph,
|
||||
applyGraphvizStyle
|
||||
};
|
||||
use function PMSIpilot\DockerComposeViz\readConfiguration;
|
||||
use function PMSIpilot\DockerComposeViz\fetchServices;
|
||||
use function PMSIpilot\DockerComposeViz\fetchVolumes;
|
||||
use function PMSIpilot\DockerComposeViz\fetchNetworks;
|
||||
use function PMSIpilot\DockerComposeViz\createGraph;
|
||||
use function PMSIpilot\DockerComposeViz\applyGraphvizStyle;
|
||||
|
||||
$application = new Console\Application();
|
||||
|
||||
$application->register('render')
|
||||
->addArgument('input-file',Console\Input\InputArgument::OPTIONAL, 'Path to a docker compose file', getcwd().DIRECTORY_SEPARATOR.'docker-compose.yml')
|
||||
->addArgument('input-file', Console\Input\InputArgument::OPTIONAL, 'Path to a docker compose file', getcwd().DIRECTORY_SEPARATOR.'docker-compose.yml')
|
||||
|
||||
->addOption('output-file', 'o', Console\Input\InputOption::VALUE_REQUIRED, 'Path to a output file (Only for "dot" and "image" output format)')
|
||||
->addOption('output-format', 'm', Console\Input\InputOption::VALUE_REQUIRED, 'Output format (one of: "dot", "image", "display")', 'display')
|
||||
|
@ -28,7 +24,7 @@ $application->register('render')
|
|||
->addOption('no-volumes', null, Console\Input\InputOption::VALUE_NONE, 'Do not display volumes')
|
||||
->addOption('horizontal', 'r', Console\Input\InputOption::VALUE_NONE, 'Display a horizontal graph')
|
||||
|
||||
->setCode(function(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) {
|
||||
->setCode(function (Console\Input\InputInterface $input, Console\Output\OutputInterface $output) {
|
||||
$inputFile = $input->getArgument('input-file');
|
||||
$outputFormat = $input->getOption('output-format');
|
||||
$outputFile = $input->getOption('output-file') ?: getcwd().DIRECTORY_SEPARATOR.'docker-compose.'.($outputFormat === 'dot' ? $outputFormat : 'png');
|
||||
|
@ -62,7 +58,7 @@ $application->register('render')
|
|||
|
||||
$services = array_filter(
|
||||
$services,
|
||||
function($service) use ($onlyServices) {
|
||||
function ($service) use ($onlyServices) {
|
||||
return in_array($service, $onlyServices);
|
||||
},
|
||||
ARRAY_FILTER_USE_KEY
|
||||
|
@ -77,7 +73,7 @@ $application->register('render')
|
|||
switch ($outputFormat) {
|
||||
case 'dot':
|
||||
case 'image':
|
||||
$rendererClass = 'Graphp\GraphViz\\' . ucfirst($outputFormat);
|
||||
$rendererClass = 'Graphp\GraphViz\\'.ucfirst($outputFormat);
|
||||
$renderer = new $rendererClass();
|
||||
|
||||
file_put_contents($outputFile, $renderer->getOutput($graph));
|
||||
|
|
|
@ -76,7 +76,6 @@ function fetchNetworks(array $configuration) : array
|
|||
return $configuration['networks'] ?? [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @public
|
||||
*
|
||||
|
@ -338,8 +337,8 @@ function addPort(Graph $graph, int $port, string $proto = null)
|
|||
/**
|
||||
* @internal
|
||||
*
|
||||
* @param Graph $graph Input graph
|
||||
* @param string $path Path
|
||||
* @param Graph $graph Input graph
|
||||
* @param string $path Path
|
||||
*
|
||||
* @return Vertex
|
||||
*/
|
||||
|
@ -358,9 +357,9 @@ function addVolume(Graph $graph, string $path)
|
|||
/**
|
||||
* @internal
|
||||
*
|
||||
* @param Graph $graph Input graph
|
||||
* @param string $name Name of the network
|
||||
* @param string $type Network type
|
||||
* @param Graph $graph Input graph
|
||||
* @param string $name Name of the network
|
||||
* @param string $type Network type
|
||||
*
|
||||
* @return Vertex
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue