Skip to content

Commit

Permalink
removed lots of dependancies to reduce the chance of conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug committed Apr 13, 2016
1 parent 3476c9d commit 7a33aa1
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 262 deletions.
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
],
"require": {
"silktide/syringe": "^1.1",
"symfony/console": "^3.0",
"monolog/monolog": "^1.19",
"symfony/monolog-bridge": "^3.0",
"symfony/event-dispatcher": "^3.0"
"symfony/console": "~2.8|^3.0"
},
"autoload": {
"psr-4": {
Expand Down
240 changes: 2 additions & 238 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions src/Loggable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php


namespace Silktide\SyringeVerifier;


trait Loggable
{
public function success($message)
{
$this->log($message, "\033[32m");
}

public function log($message, $color="")
{
echo $color.$message."\033[0m\n";
}

public function error($message)
{
$this->log($message, "\033[31m");
}
}
35 changes: 15 additions & 20 deletions src/VerifyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@

namespace Silktide\SyringeVerifier;

use Downsider\PuzzleDI\Helper\PuzzleDataCollector;
use Monolog\Logger;
use Psr\Log\LoggerTrait;
use Psr\Log\LogLevel;
use Silktide\Syringe\ContainerBuilder;
use Silktide\Syringe\Loader\JsonLoader;
use Silktide\Syringe\Loader\YamlLoader;
use Silktide\Syringe\ReferenceResolver;
use Silktide\Syringe\SyringeServiceProvider;
use Silktide\SyringeVerifier\Parser\ComposerParser;
use Silktide\SyringeVerifier\Parser\ComposerParserResult;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class VerifyCommand extends Command
{
use Loggable;

protected $composerParser;
protected $log;
protected $input;
Expand All @@ -32,7 +26,6 @@ public function __construct()
{
parent::__construct();
$this->composerParser = new ComposerParser();
$this->log = new Logger("SyringeVerifier");
}

public function configure()
Expand All @@ -48,8 +41,6 @@ public function execute(InputInterface $inputInterface, OutputInterface $outputI
$this->input = $inputInterface;
$this->output = $outputInterface;

$this->log->setHandlers([new ConsoleHandler($outputInterface, null, [LogLevel::DEBUG])]);

// 1. Work out what directory we're caring about
$directory = getcwd();
// That was easy
Expand All @@ -58,31 +49,32 @@ public function execute(InputInterface $inputInterface, OutputInterface $outputI
$parserResult = $this->composerParser->parse($directory."/composer.json");

if (!$parserResult->usesSyringe() && !$inputInterface->getOption("force")) {
$this->log->critical("The project in this directory '{$directory}' is not a library includable by syringe via Puzzle-DI");
$this->error("The project in this directory '{$directory}' is not a library includable by syringe via Puzzle-DI");
return 1;
}

$container = $this->setupContainer($parserResult);

$this->log->info("Attempting to build all services!");
$this->log("Attempting to build all services!");
$this->log(count($container->keys())." services/parameters found!");
/** @var \Exception[] $exceptions */
$exceptions = [];
foreach ($container->keys() as $key) {
try{
$build = $container[$key];
} catch (\Exception $e) {
$exceptions[] = [$e->getMessage(), $e->getFile(), $e->getLine()];
$exceptions[] = $e;
}
}

if (count($exceptions) > 0) {
$this->log->crit("Failed to successfully build ".count($exceptions)." bits of DI config");
$table = new Table($outputInterface);
$table->setHeaders(["Message", "File", "Line"]);
$table->setRows($exceptions);
$table->render();
$this->error("Failed to successfully build ".count($exceptions)." bits of DI config");
foreach ($exceptions as $e) {
$this->log(" Message:".$e->getMessage().". File: ".$e->getFile().". Line: ".$e->getLine());
}
return 1;
} else {
$this->log->info("Succeeded!");
$this->success("Succeeded!");
return 0;
}
}
Expand Down Expand Up @@ -114,6 +106,9 @@ public function setupContainer(ComposerParserResult $parserResult)
}

$additionalConfigs = $this->input->getOption("configs");
foreach ($additionalConfigs as $config) {
$builder->addConfigFile(realpath($config));
}
$builder->addConfigFiles($parserResult->getConfigList());


Expand Down

0 comments on commit 7a33aa1

Please sign in to comment.